When designing a PCB for an STM32 (and drop-in replacements) microcontrollers, I need to place some crystals for the low and high frequency clocks. The thing I am looking at is what the value for the caps at the crystals should be. I have found this
https://blog.adafruit.com/2012/01/24/choosing-the-right-crystal-and-caps-for-your-design/ stating the rule of thumb is
C1 - C2 = 2*CL – 2*Cstray
So, the C
L value is the value in the capacitor datasheet. The C
stray is the capacitance of the PCB. I'm not sure how to determine this value, but as the article suggests, I've used a value of 5 pF.
Now, let's say, I have a crystal 8 MHz, 20 pF. This would give me (2*20)-(2*5)= 30 pF. And for the 32 kHz crystal, I've got 7 pF. (2*7) - (2*5) = 4 pF. Now, when I build a board with these components, and I use a STM32F103C8T6 microcontroller, the low frequency clock starts fine. However, when I use a GD32F103C8T6, the low frequency clock doesn't start. When I replace the caps with 15 pF caps, the low frequency clock does start.
One thing I notice, in the datasheet, for the STM part it states the recommended load capacitance is max 15 pF. For the GigaDevice part it says max 20 pF. As these values say max, I've interpreted it as the value should be below, and 7 is below both values. I realise the input pins themselves have some capacitance as well. But I am not sure what this value is, and if this value is included in C
stray.
Basically, when using a higher value of capacitor, the GigaDevice part works. So, is this formula I'm using any good, or do I need a different approach for choosing crystals and caps.