I have designed a PCB using a PIC18F6520 and a 32MHz crystal. Using a breadboard with a PIC16F877A, my code works great. But when I load a simple LED blinking program onto my PCB, the LED flickers when I touch around the crystal and does nothing otherwise. The capacitors are 22pF, which gives a load capacitance of 11pF (the crystal specifies 12pF)

The relevant section of my PCB is attached below (please note that I have turned off the ground pour for better visibility, but it is there):


And here's the corresponsing section of schematic:


  • \$\begingroup\$ Comments: (1) Do you have a damping resistor across the crystal? Adding a schematic snippet to the question would not hurt. (2) Experiment. If you replace this crystal with a lower frequency (and update the firmware), does the PIC behave correctly? (3) We've got a couple of threads about uC crystal layout: this, this, there's probably more. \$\endgroup\$ Feb 28 '16 at 22:39
  • \$\begingroup\$ @Nick (1) No, and I can add that. (2) Same behavior with a 20MHz crystal. (3) Thanks, I'll look at those \$\endgroup\$ Feb 28 '16 at 22:41
  • \$\begingroup\$ Do you have the PLL disabled? Normally you'd use an 8MHz crystal with PLL to get 32MHz. \$\endgroup\$ Feb 28 '16 at 23:11
  • \$\begingroup\$ @sphero I think it's disabled, in that I'm not explicitly enabling it anywhere. How could I tell? \$\endgroup\$ Feb 28 '16 at 23:19

The maximum crystal frequency that you can use with the PIC18F6520 depends on whether you have the PLL enabled. With it disabled you can use a crystal up to 25MHz (page 320 of the datasheet). With it enabled you are limited to the range 4 to 10MHz.

This certainly explains why the 32MHz crystal does not work reliably. I'm not sure why the 20MHz crytal doesn't work, but perhaps you have the PLL enabled? Or you are running the PIC from a much lower Vdd than 3.3V?

  • 1
    \$\begingroup\$ Also make sure the correct oscillator block is chosen. An incorrect choice will prevent it from operating. \$\endgroup\$
    – rdtsc
    Feb 29 '16 at 12:50
  • \$\begingroup\$ I took a video: youtu.be/HcamSDb0YCc that's with a 20MHz crystal and HS + NOOSCSEN fuses set. PIC is running at 5V \$\endgroup\$ Feb 29 '16 at 16:57
  • \$\begingroup\$ That should be blinking at 1Hz (500ms on, 500ms off) \$\endgroup\$ Feb 29 '16 at 17:18

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.