Chris Collins

Tools · electronics

Crystal oscillator

Size the load capacitors for a microcontroller's crystal from its load capacitance and the board's stray capacitance, estimate the frequency error of the capacitors you fit, and check the oscillator's gain margin and the crystal's drive level.

Added

How to use it

Almost every MCU uses a Pierce oscillator: an inverting amplifier with the crystal in the feedback path and a capacitor from each crystal pin to ground.

  • Load capacitors — the crystal is cut for a load capacitance CL. The two capacitors appear in series, plus the stray capacitance of the pins and traces: CL = C1·C2/(C1 + C2) + Cstray, so for equal capacitors C = 2·(CL − Cstray).

  • Frequency pulling — with the crystal’s motional capacitance, the error from a load that differs from CL: Δf/f ≈ C1m·(CLspec − CL)/(2·(C0 + CLspec)·(C0 + CL)).

  • Gain margin — the critical transconductance gm_crit = 4·ESR·(2πf)²·(C0 + CL)²; the MCU’s oscillator gm should be at least five times that for reliable start-up.

  • Drive level — DL = ESR·(π·f·(C0 + CL)·Vpp)²/2 against the crystal’s maximum; reduce it with a series resistor if needed.

References: ST AN2867 Oscillator design guide for STM8AF/AL/S, STM32 MCUs and MPUs; Microchip AN826 and AN2648. Related: capacitors, MCU timing.

Runs entirely in your browser; nothing you type leaves this page.