When designing a circuit recently, I was faced with selecting appropriate load capacitors for the crystal oscillator on my microcontroller. While in the end this selection is rather straightforward, finding the relevant information can be a challenge. My Google searches weren't as helpful as I'd hoped they'd be, and I had to pull together information from several sources. I wrote this blog post to pull together all of the information I found into a single page that hopefully can serve as a reference for others.
So let's begin: what are load capacitors and why are they needed?
The oscillator used by most (all?) microcontrollers is known as a Pierce oscillator. To quote Wikipedia:
The Pierce oscillator is a type of electronic oscillator particularly well-suited for use in piezoelectric crystal oscillator circuits. Named for its inventor, George W. Pierce (1872-1956), the Pierce oscillator is a derivative of the Colpitts oscillator. Virtually all digital IC clock oscillators are of Pierce type, as the circuit can be implemented using a minimum of components: a single digital inverter, two resistors, two capacitors, and the quartz crystal, which acts as a highly selective filter element. The low manufacturing cost of this circuit, and the outstanding frequency stability of the quartz crystal, give it an advantage over other designs in many consumer electronics applications.
In order to oscillate correctly, the oscillator needs a certain amount of capacitance across the leads of the crystal. This capacitance, known as the "load capacitance," forms an essential part of the oscillator circuit.
The required load capacitance is specified by the crystal manufacturer in the datasheet, usually as CL. The crystal manufacturer is saying that if the capacitance across the leads of the crystal is equal to CL, the crystal will resonate at its specified frequency.
A naive solution to this problem is to simply use a single capacitor, of CL, across the leads of the crystal. Unfortunately, things aren't quite this easy. The naive solution looks like this:
However, it's never done that way. Instead, load capacitors are placed from each lead of the crystal to ground. (I don't know why this is; I haven't yet found a good explanation in my research. If you have a good explanation, let us know in the comments!) The typical solution looks like this:
Note that electrically, this is equivalent to two capacitors in series, with the circuit's ground on the segment between the two load capacitors. We can redraw the above circuit like this:
Now we have a problem we can solve. If we want the capacitance across the leads of the cystal to be CL, and we have two capacitors in series, we can figure out what value C to use for the capacitors. The formula for capacitors in series is:
For two capacitors, this formula reduces to:
If we set C1 = C2 (which is almost always going to be the case with crystal load capacitors), and call that value C, we can further reduce this equation to:
So, it would appear that if we need to find C such that C/2 = CL, we should choose C = 2(CL), right?
Well... almost. If the load capacitors were the only capacitance across the leads of the crystal, that would indeed be the case. However, there are additional sources of capacitance in the oscillator circuit. The first source is the "stray capacitance" of the circuit board traces. The second is the input capacitance of the oscillator circuit on the microcontroller.
The input capacitance of the microcontroller's oscillator is specified in the datasheet. For the Atmel ATSAM3S controller I'm considering, it's specified in table 42-18 of the datasheet as 1pF typical.
The stray capacitance of the circuit board is a bit more difficult to come by. Apparently, this is a difficult measurement to make, so the usual approach is to just guess. I've seen anything from 2pF to 5pF given as an appropriate value, and 3-5pF seems to be the most common guess.
The crystal I've chosen for my circuit requires a load capacitance of 12.5pF to oscillate at its rated frequency. Choosing the load capacitors, then, looks like this:
For this circuit, then, I'm going to use 18pF capacitors for C1 and C2.
So what happens then if we choose the wrong value for the load capacitors?
Quoting Microchip App Note AN826 (linked below), crystals can be pulled from their specified operating frequency by adjusting the load capacitance the crystal sees in the circuit. An approximate equation for crystal pulling limits is:
Δf = the pulled crystal frequency minus fs
fs = the crystal's resonant frequency
C1 = the motional arm capacitance of the crystal
C0 = the shunt capacitance of the crystal
CL = the actual load capacitance across the crystal's leads
Whoa! These are new terms. What the heck do C0 and C1 represent? Well, a crystal actually has complex electrical properties. The electrical behavior of a crystal can be modeled like this:
The shunt capacitance, C0, is the capacitance of the crystal's leads and package and is the only real value in the equivalent circuit. C1 is an equivalent value, a value that only exists in the model. Actual measurements for these values may or may not (and probably won't) be given in the crystal's datasheet. The crystal I'm using has a shunt capacitance C0 of 1.35pF typical, but the value C1 is not given. I was able to find one reference that gave typical values for C1 as 5-30fF (femtofarads). According to some resources I found, you might be able to pull a crystal by 100 or 200ppm. For the 32.768 kHz crystal I'm using, 100ppm would be 3.27Hz. In more realistic terms, 100ppm is about 8 seconds per day. Assuming I've chosen my load capacitors correctly, the +/- 20ppm rating of the crystal is about 1.8 seconds per day.
This is hardly a comprehensive review of the subject. I'm sure there's lots more to know about choosing capacitors that I either haven't found or don't care to dig in to. I'm hoping this information is enough to let me choose suitable capacitors for my designs, and I hope it is for you, too. But I have to say this again: just because I write a blog doesn't make me an expert.