3
\$\begingroup\$

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?

\$\endgroup\$
  • 1
    \$\begingroup\$ In the year 2013, Microchip will sell you a microcontroller that has a built-in oscillator. \$\endgroup\$ – Kaz Apr 5 '13 at 22:13
  • 1
    \$\begingroup\$ Can you post a picture of how you built this? PCB? Breadboard? \$\endgroup\$ – Kaz Apr 5 '13 at 22:14
  • \$\begingroup\$ @Kaz Build yourself a clock or try RS232 with a built-in oscillator and tell me how it goes. \$\endgroup\$ – user1354999 Apr 5 '13 at 22:55
  • 1
    \$\begingroup\$ I built a clock with an external osc. recently! Problem is, it stops whenever I touch the desk ... \$\endgroup\$ – Kaz Apr 6 '13 at 0:55
  • \$\begingroup\$ @user1354999 Some MCUs do quite well with internal oscillators for serial communications. The AVR XMEGA series definitely work reliably for this purpose. \$\endgroup\$ – Anindo Ghosh Apr 6 '13 at 5:55
2
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ +1. The reset input in question is the MCLR pin (master clear, active-low), which needs to be pulled high. See section 14.4 of the 18f87xA datasheet. \$\endgroup\$ – Chris Johnson Mar 2 '14 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.