PDA

View Full Version : PIC 16f877a



CipiCips
- 20th May 2011, 02:53
Hi

I have a very strange problem with PIC 16F877A, When I enter program into the PIC and plug PIC into circuit board and turn on the switch, everything is normal and work like it should work. But when I turn off the power and after few sec I turn it ON, PIC doesnt work corectly.

For example:
WHen I plug him after programing, my motors moves acording to AD conversion, but when I turn it off, and after a short period when I turn it ON, PIC reads another values from AD ?

thx

mister_e
- 20th May 2011, 10:41
Various thing may do that, but I would suggest to enable the Brown-Out detect, and Power On Timer config fuses and see how better/worst it is from there.

aratti
- 21st May 2011, 10:10
The schematic could help to understand better. Can you post it?

Cheers

Al.

CipiCips
- 21st May 2011, 10:38
HI

here is the schematic:

http://img153.imageshack.us/img153/7324/evob.jpg (http://imageshack.us/photo/my-images/153/evob.jpg/)

I have tried to enable BOD, and these are results:

When I insert PIC into Board and turn the switch on, program run correctly, but when I turn the switch off and let it be offline few min, then when I turn it on it want work, BUT when I turn OFF the switch and Take out PIC from board and Plug him back to board, and turn the switch ON program runs correctly ?
So every time I Remove it from board and plug him back program works

mister_e
- 21st May 2011, 10:58
Slow slope power-on/Power off PSU behaviour.

You want to test the BOR, PD bits at the start of the program then.

Check the datasheet for STATUS, PCON register

CipiCips
- 21st May 2011, 11:16
I am lil bit confused now ?? how to chack that ?

aratti
- 21st May 2011, 11:24
What is the state of all the unused and floating pins ? Are they outputs or inputs ?
If you have them set (tris setting) as input then turn them into output and clear them to zero.

Never leave inputs floating without pullup or pulldown.

Cheers

Al.

CipiCips
- 21st May 2011, 11:37
Hmm

so I should put all my pins (register E,C ect.) that I am not using to OUTPUT

Archangel
- 21st May 2011, 19:15
Hmm

so I should put all my pins (register E,C ect.) that I am not using to OUTPUT
Setting them to low outputs gives them a low impedance potential. As inputs with a high impedance potential they are subject to "Stray capacitance" electric fields which typically have relatively high voltage and very low current available. If you need them as inputs, you would either enable weak pullups, tie them to either ground or VDD with resistors depending on your need, again lowering their input impedance to several hundred to a few thousand ohms, exception: If you WANT to use them as capacitor plates, maybe a touch sensor.
You might find some value here:
http://www.electronic-engineering.ch/microchip/projects/keyboard/kbd_box/kbd_box_keypad.pdf
http://www.electronic-engineering.ch/microchip/projects/keyboard/box_dbg/box_dbg.html

I like how they use a comparator to trigger an interrupt to check the keyboard register.