1

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):

PCB

And here's the corresponsing section of schematic:

Schematic

Erik Johnson
  • 159
  • 1
  • 11
  • 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](http://electronics.stackexchange.com/a/5608), [this](http://electronics.stackexchange.com/q/39136), there's probably more. – Nick Alexeev Feb 28 '16 at 22:39
  • @Nick (1) No, and I can add that. (2) Same behavior with a 20MHz crystal. (3) Thanks, I'll look at those – Erik Johnson Feb 28 '16 at 22:41
  • Do you have the PLL disabled? Normally you'd use an 8MHz crystal with PLL to get 32MHz. – Spehro Pefhany Feb 28 '16 at 23:11
  • @sphero I think it's disabled, in that I'm not explicitly enabling it anywhere. How could I tell? – Erik Johnson Feb 28 '16 at 23:19

1 Answers1

3

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?

Steve G
  • 5,275
  • 1
  • 13
  • 24
  • 1
    Also make sure the correct [oscillator block](http://ww1.microchip.com/downloads/en/DeviceDoc/39609C.pdf#page=21) is chosen. An incorrect choice will prevent it from operating. – rdtsc Feb 29 '16 at 12:50
  • I took a video: https://youtu.be/HcamSDb0YCc that's with a 20MHz crystal and HS + NOOSCSEN fuses set. PIC is running at 5V – Erik Johnson Feb 29 '16 at 16:57
  • That should be blinking at 1Hz (500ms on, 500ms off) – Erik Johnson Feb 29 '16 at 17:18