I've been trying to figure this issue out for a couple days now, reading up on typical crystal operation / configuration, and I'm at a loss. I tried searching here but didn't encounter anything similar to my issue, so I'm sorry if I missed my solution somewhere.
I'm trying to run an RTC off of an external crystal using a PIC, but the crystal isn't oscillating when I expect it to, and is oscillating under other circumstances, and I can't make any sense of it. I'm not an EE though, so I'm probably just being super ignorant.
The crystal: LFXTAL016178. I'm fairly certain that because nothing is listed, it's a parallel resonant crystal. Its load capacitance is 6 pF, which I've found to be sort of uncommon? I'm not sure.
The PIC: PIC24FJ128GB204. I've connected the crystal as the datasheet suggests, but it doesn't provide much explicit help in selecting load capacitors, so I did some searching and found other resources online to help me there.
The setup: I saw from a couple sources that a good rule of thumb for load capacitors is \$C_L = \frac{C_1 × C_2}{C_1+C_2}\$, adding stray capacitance to \$C_1\$ and \$C_2\$ of between 2 and 5 pF. I picked what I thought was a middle value of 6pF for both capacitors, and I'm still not sure how bad that selection was.
Here is a picture of my schematic:
Layout:
Cases where it doesn't work:
- As it is in the schematic, with 6pF load capacitors on both pins, it doesn't oscillate. Unless it oscillates every 10 minutes or something.
- With the capacitors removed, it oscillates extremely slowly, maybe approximately 2.5 times slower than it should. I didn't measure this speed.
- With extra 6pF capacitors soldered on top to make 12pF capacitors, it doesn't oscillate.
- With 3 pF capacitors and a 10 MOhm resistor across the pins. (RTCC clock is erratic.)
Cases where it does work:
- When I probe the SOSCI pin with an oscilloscope. In the first three cases above, as soon as I touched the probe to the SOSCI pin, it started up and gave me a nice clean sine wave. It didn't do this when I touched the SOSCO pin, OR when I used 3pF capacitors. I know it wasn't working beforehand because of some LEDs that are supposed to blink every second, which only blinked with the probe connected. (I don't know everything about oscilloscopes, I just know how to operate them. The probe says 6MHz/1MOhm/95pF, and the scope says 60 MHz/1 GS/s and 300V CAT II where the probe connects. It's a Tektronix TDS 2002 if that means anything to anyone.)
- When I connect a 330 Ohm resistor between SOSCI and ground. It's one of two resistors I have on hand; the 10k looked like it made it operate at about half the right frequency.
- With 3 pF capacitors, but at 14 kHz.
Here are some frequencies that I've measured:
- (12 pF Caps) Frequency touching probe to SOSCI: 32.7674 kHz
- (12 pF Caps) Frequency output by PIC with the 330-ohm pull-down on SOSCI: 32.764 kHz
- (12 pF Caps) Frequency output by PIC using LPRC: 32.68 kHz
- (3 pF Caps) Frequency output by PIC: 14.08 kHz
Basically, what I'd like to know is why it oscillates perfectly sometimes when I use a scope probe, and what the correct solution should be in order to make it work as I want it to.
EDIT: I've only just found this application note, where it says that I should have selected a 12.5 pF \$C_L\$ crystal for my microcontroller. However, any crystals on Mouser/Digikey with my desired minimum operating temperature (-55\$^{\circ}\$C) are out of stock. I'll be getting one that will suffice for now, but I think my questions still stand.
EDIT2: With a fancy new crystal (\$C_L\$=12.5 pF) and some standard 22 pF caps, it worked at 32.7676 kHz. What does this imply about what went wrong with the old crystal (\$C_L\$=6 pF)?