Choosing Crystal Load Capacitors (and Other Oscillator Maths)
How to pick load capacitors for a microcontroller crystal, why the wrong values shift the clock, and frequency formulas for 555, Wien and LC oscillators.
&c=%231e3a8a&k=engineering)
Choosing Crystal Load Capacitors (and Other Oscillator Maths)
A microcontroller's crystal looks like the simplest part of a design: a little metal can with two capacitors. Get those capacitors wrong, though, and the clock runs fast or slow, USB fails to enumerate, serial ports garble characters, or the oscillator refuses to start on cold mornings. The free Oscillator and Crystal Calculator calculates crystal load capacitors and the frequencies of common oscillator circuits.
Load capacitance explained
A quartz crystal is cut to oscillate at its marked frequency when it sees a particular capacitance, the load capacitance CL, given in its datasheet: often 8, 12, 18 or 20 pF. In the usual Pierce oscillator inside a microcontroller, the crystal sees the two external capacitors in series, plus stray capacitance from the chip's pins and the board traces:
CL = (C1 × C2) / (C1 + C2) + Cstray
With equal capacitors, this rearranges to C1 = C2 = 2 × (CL − Cstray). Stray capacitance is typically 2 to 5 pF. So an 18 pF crystal with 4 pF of stray capacitance needs 28 pF capacitors; the nearest standard E12 value is 27 pF, giving 17.5 pF.
A common mistake is to fit capacitors equal to CL, such as 18 pF for an 18 pF crystal. That gives a load of about 13 pF, so the crystal runs fast, by a few ppm per pF.
Why a few ppm matter
A ppm is one part per million: 20 ppm on a 32.768 kHz watch crystal is about 52 seconds per month. USB full speed tolerates ±2,500 ppm, but real-time clocks, radio modules and precise timing need much better. Many modern microcontrollers have adjustable internal load capacitors, so check the datasheet before adding parts.
Making sure it starts
An oscillator needs enough gain to start. Crystal datasheets give an equivalent series resistance (ESR) and a maximum drive level; microcontroller datasheets give a transconductance or a recommended crystal. A common guideline is a negative resistance margin of at least five times the ESR. Too much load capacitance reduces the margin.
Other oscillators
The calculator also covers circuits found in textbooks and kits:
- Wien bridge: f = 1 / (2πRC), with amplifier gain exactly 3; a clean sine source.
- RC phase shift: three RC sections give f = 1 / (2πRC√6), with gain 29.
- Colpitts and Hartley: LC oscillators for radio frequencies, using a capacitive or inductive divider for feedback.
- 555 astable: f = 1.44 / ((R1 + 2R2) C), with a duty cycle above 50% unless a diode bypasses R2.
- PLL: multiplies a reference by N and divides by M and P. The output inherits the reference's ppm error.
Layout matters
Crystal circuits are sensitive to the board layout. Place the crystal and its capacitors as close to the microcontroller's pins as possible, keep the traces short, surround them with a ground area connected to the chip's ground, and keep fast digital signals and switching regulators away. Long traces add stray capacitance and pick up noise, which shifts the frequency and can stop the oscillator starting.
Checking the result
The best check is measurement. Many microcontrollers can output their clock on a pin; measure it with a frequency counter that is more accurate than the crystal, at the extremes of temperature the product will see. If the frequency is consistently high, add a little load capacitance; if low, reduce it.
Step by step
- Choose the circuit.
- Enter the crystal's CL and the stray capacitance, or the component values.
- Read the capacitor values or the frequency.
- Pick the nearest standard parts.
- Measure the real frequency on the bench and adjust.
The calculator runs in your browser.



