← How-Tos
electronics Aug 21, 2026 ◑ 3 views ◯ 4 min read

Crystal Oscillators and Resonators for Makers: Quartz, Ceramic, and Clock Circuit Design

crystal oscillatorceramic resonatorclock circuitload capacitancertcpcb designavresp32

Every microcontroller in your parts bin needs a stable clock to run its instructions at a known rate, and most boards get that clock from a tiny two-legged (or four-pin) component you've probably never thought about: a crystal or ceramic resonator. This guide explains how these parts actually generate a frequency, why your ESP32 dev board has one 40MHz crystal and your Arduino Uno has another running at 16MHz, when you need to add your own external crystal to a bare-chip design, and the layout mistakes that turn a rock-solid clock into a flaky one.

How a Crystal Makes a Stable Frequency

A quartz crystal exploits the piezoelectric effect: mechanically deform a precisely-cut sliver of quartz and it generates a voltage; apply a voltage and it physically deforms. Cut to the right dimensions, that sliver has a natural mechanical resonance at a very specific, very stable frequency. Pair it with an on-chip (or external) oscillator circuit that keeps re-exciting it at that resonance, and you get a clock signal that's accurate to within a few dozen parts per million — dramatically more stable than an RC oscillator, which drifts with temperature, supply voltage, and manufacturing tolerance.

Ceramic resonators work on the same piezoelectric principle using a ceramic material instead of quartz. They're cheaper and often come as a 3-pin package with built-in load capacitors, but they're less accurate (tens of thousands of ppm vs single-digit-to-low-double-digit ppm for a good crystal) and drift more with temperature. That's a fine trade for a UART baud rate clock; it's not fine for anything timing-critical like precision data logging or RF.

TypeTypical AccuracyCostCommon Use Quartz crystal (HC-49 or SMD)10-50 ppmLowMCU system clock, USB timing, RTC (32.768kHz) TCXO (temperature-compensated)0.5-2 ppmModerateGPS, LoRa, cellular modules where frequency drift breaks the radio link Ceramic resonator0.5-1% (5,000-10,000+ ppm)Very lowNon-critical UART/general MCU clocking MEMS oscillator10-50 ppmModerateVibration-resistant applications, drop-in crystal replacement 32.768kHz "watch crystal"20 ppmLowRTC ICs (DS3231, PCF8563), MCU deep-sleep timers

Why 32.768kHz Specifically?

You'll see this exact frequency on nearly every real-time clock module, including the DS3231 covered in this site's Real-Time Clock Modules guide. It's not arbitrary: 32,768 is 2¹⁵, so a simple 15-stage binary counter divides it down to exactly 1Hz — one tick per second — with pure digital logic and no messy division ratios. It's also low enough in frequency to sip almost no power, which matters when an RTC crystal has to keep ticking for years off a coin cell.

Load Capacitance: The Detail That Breaks Homebrew Designs

This is the single most common mistake when adding an external crystal to a bare AVR or STM32 design (see this site's Programming Bare AVR Chips guide for a related bare-chip workflow). A crystal's datasheet specifies a load capacitance (CL) — commonly 12pF, 18pF, or 20pF — which is the capacitance the crystal expects to see across it to oscillate at its rated frequency. You supply that via two small capacitors, one from each crystal pin to ground, sized using:

C(each) ≈ 2 × CL − C(stray)

where stray capacitance from PCB traces and the chip's pins is typically 2-5pF. Get this wrong and the crystal doesn't fail outright — it oscillates at a slightly wrong frequency (frequency pulling), which is exactly the kind of subtle bug that shows up as intermittent UART garbage or USB enumeration failures under specific temperature conditions and drives people to replace perfectly good boards.

Layout Rules That Actually Matter

When You Don't Need an External Crystal

Modern parts increasingly have internal RC oscillators accurate enough for many jobs — the ESP32 series can run its main CPU clock from an internal oscillator disciplined against the external 40MHz crystal only for RF-critical timing, and many ATtiny/ATmega parts have a factory-calibrated internal 8MHz oscillator accurate to roughly 1-2% out of the box, good enough for most non-UART, non-RF work. Skip the external crystal (and the two capacitors and two GPIO pins it costs you) unless you specifically need USB timing, RF timing, or a hardware RTC — in which case there usually isn't a substitute.

It's a two-pin, few-cent component that almost nobody thinks about until it's the reason a board won't boot reliably — understanding what it's actually doing, and getting the load capacitance right, turns "mysteriously flaky at 3am" bugs into a five-minute datasheet check.