Electronic – PIC16F877A latchup/glitching

microcontrolleroscillatorpic

I have a PIC16F877A microcontroller with a 19.6608 MHz crystal, wired for 12V ICSP. I can reprogram the chip just fine, and it runs almost flawlessly (it's blinking an LED right now as I type). Only thing is, the PIC seems to latch up or stop its oscillator when I get up from my chair and touch the metal frame of the table it is sitting on. I sit back down, touch the metal frame again, and the PIC starts blinking the LED again. Sometimes it takes more than one "cycle" to get the PIC started again. Weird…

I made sure to select the right oscillator mode (HS), disable the watchdog timer, set unused pins to outputs, use decoupling capacitors, etc. I made sure I selected the correct capacitors for the crystal I'm using.

Any suggestions as to the cause of this flakiness?

Best Answer

The most likely culprit is the reset input is not pulled high (or low, cannot remember) with a resistor to keep noise from triggering it. Look at the default circuits for PIC MCUs for the reset input.