Crystal Oscillator Circuits: Building a Reliable Clock Source

2026-04-30

Every digital system needs a clock, and quartz crystals give you frequency accuracy that RC or LC oscillators can't touch — typically ±30 ppm versus ±5% or worse. Understanding how to build a crystal oscillator from discrete components is fundamental, even if you usually just drop in a pre-packaged oscillator module.

How a quartz crystal works: A quartz crystal is a mechanical resonator with an electrical equivalent circuit: a series RLC branch (called the "motional" arm) in parallel with the package capacitance C₀. This gives the crystal two resonant frequencies — a series resonance fₛ where it looks like a low impedance, and a parallel (anti-resonance) fₚ slightly higher where it looks like a high impedance. Most microcontroller clock circuits operate between these two frequencies in "parallel resonant" mode.

The Pierce oscillator: This is the topology you'll encounter most often. It uses a single inverting gate (or inverter-connected CMOS pin) with the crystal connected from output to input, and two capacitors — C₁ from the input to ground, C₂ from the output to ground. A feedback resistor (typically 1 MΩ) biases the inverter into its linear region. The crystal operates in its inductive region between fₛ and fₚ, and the two capacitors provide the necessary phase shift for oscillation.

Choosing load capacitors: The crystal datasheet specifies a "load capacitance" C_L — typically 12–20 pF. Your job is to make the external circuit present that capacitance to the crystal. The formula is:

C_L = (C₁ × C₂) / (C₁ + C₂) + C_stray

C_stray accounts for PCB traces and pin capacitance, usually 3–5 pF. For a crystal specifying C_L = 18 pF with 5 pF stray capacitance, you need the series combination of C₁ and C₂ to equal 13 pF. Using equal capacitors: C₁ = C₂ = 26 pF (pick the nearest standard value, 27 pF). Getting this wrong shifts the oscillation frequency and can prevent startup entirely.

Real-world example: A 16 MHz crystal on an ATmega328P (the Arduino Uno's MCU). The datasheet recommends C_L = 20 pF. Assuming 5 pF stray, you need 15 pF from the caps, so C₁ = C₂ = 30 pF — which is why Arduino boards use two 22 pF caps (a slight compromise that works in practice).

Practical tips:

See it in action: Check out Soyuz Clock Part 7: Taming the Glitches in our Space Clock Crystal Oscillator by CuriousMarc to see this theory applied.
Key Takeaway: A Pierce crystal oscillator needs just an inverter, two load capacitors sized to match the crystal's specified C_L, and a bias resistor — get the load capacitance right and keep your layout tight for a rock-solid clock.

All newsletters