The topic of discussion is on a commonly used crystal configuration that uses parallel load capacitors, otherwise known as a Pierce oscillator.
Most often the best starting point of selecting load capacitors for a crystal oscillator is the datasheet of the device being driven. To give an example, an ATMEGA328PB-MU
Please note the 16Mhz crystal would be used in a 5V application. Lower voltages like 3.3V would dictate that a slower crystal would need to be used in the application, for 3.3V Microchip would advise changing the crystal speed to something like 8Mhz.
Ce - external capacitors, C1 and C2 in the schematics
Ci is the pin capacitance
CL is the load capacitance specified by the crystal manufacturer
CS is the total stray capacitance for one XTAL pin on the microcontroller.
Let’s go ahead and pull the components used on the manufacturer’s demonstration board as an example, the ATMEGA328PB-XMINI
Crystal used on the board is Mfg PN:
Manufacturer’s specified Load Capacitance for this crystal is 9pF.
Common Stray Capacitance values often fall in the 2pF to 5pF range. Make sure to locate the crystal as close to the microcontroller as possible to avoid preventable issues with this value.
So to use the above formula
( 2 x Load Capacitance of Crystal ) - Stray Capacitance
( 2 * 9pF ) - 5pf = 13pF
Checking the schematic of the Xplained Mini ATMEGA328PB board shows they used 12pF load capacitors
In most cases the above information is enough to pull off a successful oscillator circuit.
However, this stray capacitance value is unknowable because a majority of people cannot measure the actual stray capacitance. Also a designer may have not followed best practices to put the crystal as close to the part as possible.
In times where crystal oscillator reliability is critical, and ambient temperatures may effect the capacitors operation, a designer can follow a practice known as the Safety Factor.
The quick and dirty way of experimenting with the Safety Factor is to take the above Load Capacitance formula as a starting point, in this case 13pF and begin plugging in capacitor values into the circuit progressively lower and higher than the 12pF value provided in the example schematic until the circuit fails.
Document the failure value below and above 13pF, lets say for example it fails at 5pF and 25pF.
Take the median of 5pF and 25pF, ( 5pf + 25pF ) / 2 = 15pF
Also, if it’s a rugged application perform these tests under temperatures the circuit will experience in the field.
This test will take into account the stray capacitance in the circuit, that new value, 15pF will be a more reliable value than the formula provided. It’s a good idea to perform this test if the reliability of the circuit is critical, or as a way to troubleshoot intermittent crystal failures.
One shortfall of crystal oscillators is mechanical shock/vibration can cause them to fail, in these cases it’s advisable to use an external MEMS oscillator.