Why a crystal oscillator won't start or runs off frequency
The prototype boots on your bench. Then one unit out of a handful sits dead until you touch it with a probe. Or the radio works but the timing is off, or the real-time clock loses minutes a week. All of these often trace back to the same two small parts: a crystal and two capacitors.
A crystal oscillator on a microcontroller is not a clock chip. It is an amplifier inside the MCU, a crystal outside it, and a loop between them that you complete with your own parts and your own copper. The chip vendor cannot choose those for you. That is why it fails in ways a schematic review does not catch.
What the circuit is actually doing
Check your chip’s documentation to see which oscillator arrangement it uses. In a Pierce-style arrangement, the chip’s inverting amplifier drives the crystal through one pin and senses it on the other, with one capacitor from each pin to ground. Those capacitors, together with the crystal, set the frequency.
Two separate questions come out of that:
- Will it start? The amplifier has to supply enough gain to overcome the crystal’s losses. Check your chip’s oscillator documentation for how it specifies the startup requirement and what margin it recommends, and leave room beyond that minimum. A design with a thin margin may start on a good day and fail on a cold, humid or low-voltage one.
- Will it run at the right frequency? The crystal is specified to oscillate at its rated frequency only when it sees a specific load capacitance. Give it a different load and it runs fast or slow. Nothing breaks. The clock is simply wrong.
Startup is a margin problem. Frequency is an arithmetic problem. They share parts, so fixing one can hurt the other.
Load capacitance: the arithmetic people skip
The crystal datasheet gives a load capacitance, written CL. The capacitors you place are not that value. The crystal sees the two capacitors in series, plus stray capacitance from the chip’s pins and your traces. Work out the capacitor values from the crystal’s CL while allowing for that stray contribution, using the equation in your chip’s documentation.
The load is set by the external capacitors plus pin and PCB capacitance, and some parts offer on-chip adjustable capacitors so you can tune without changing the board. Check the oscillator section of your chip’s datasheet for the exact equation and range on the part you are using. The stray value in a vendor’s example is not your board’s value, and it changes with your stackup and trace length.
Common mistakes to avoid:
- Using the crystal’s CL as the capacitor value. Strays are then added on top of the intended load, so the crystal sees the wrong capacitance and the clock is off frequency.
- Copying capacitor values from a reference design with a different crystal. The reference design’s values were chosen for its crystal and its layout.
- Ignoring the chip’s internal capacitance options. Some parts have it, some do not. A family sibling may differ, so check the specific part.
- Treating the capacitors as decoupling. They are frequency-setting parts. Prefer a stable dielectric over a cheap, loose-tolerance ceramic, and check the capacitor datasheet for how its value changes with temperature.
The way to find out where you are is to measure. Put a high-impedance, low-capacitance probe on the oscillator and you will change the result, because the probe adds load. Instead, output the clock on a pin the chip provides for that purpose (many MCUs can route a clock to a pin) and measure that with a frequency counter. Compare it to nominal. A consistent offset points to load capacitance. A wandering one points to something else, such as noise or marginal startup.
Startup margin: choose a crystal the chip can drive
Every MCU oscillator specifies what crystals it can drive: a limit on ESR (equivalent series resistance), on load capacitance, and often on shunt capacitance (C0). The oscillator circuitry is on the chip, but choosing the crystal and external capacitors is your job, so check those limits before you pick parts. A poor match can leave a board that starts unreliably or drifts over temperature.
The practical rules:
- Prefer a lower CL. A crystal with a smaller load capacitance needs smaller capacitors and is generally easier for the amplifier to start. Choose crystals with load and shunt capacitance below the maximum the chip allows, not at it.
- Prefer lower ESR. The lower the crystal’s losses, the more margin you have. Check the ESR of very small packages, and question first a very small crystal paired with a low-power oscillator.
- Check the low-frequency crystal separately. Check your chip’s documentation for the limits on its 32.768 kHz oscillator, and be careful with contamination, flux residue and humidity on the board.
- Check drive level. Check your chip’s oscillator documentation and the crystal datasheet for the maximum drive level, and calculate the drive level in your circuit. If it is too high, a series resistor may be needed. Do the calculation instead of omitting the resistor because a reference design did.
When a chip has selectable drive strength or gain, firmware can matter. The wrong setting after a reset or a low-power mode can leave the oscillator marginal. Read the reference manual for the specific family, and test across power cycles, not just a warm restart.
Layout: where the margin is spent
The crystal circuit is small and high-impedance. Stray capacitance and leakage on those two nodes directly eat the margin you calculated.
- Put the crystal and both capacitors as close to the MCU pins as you can. Short, direct traces.
- Keep fast digital signals, switching regulators and antenna feeds away from the oscillator nodes. Do not route other signals underneath.
- Give the capacitors a clean ground return, and follow the vendor’s guidance on whether to pour ground under the crystal. It differs between vendors and between low-frequency and high-frequency crystals, so check the layout section of the document for your chip.
- Keep the board clean around a 32.768 kHz crystal, since flux residue between its pads can leak. Cleaning, and where appropriate conformal coating, both change what that node sees, so judge the effect with the coating on.
- Remember the footprint. A hand-drawn land pattern with long pads can add capacitance and make the crystal harder to place cleanly. Check it against the crystal’s own drawing.
If a crystal is hard to start only on some boards, look at assembly too: a lifted pad, a cracked ceramic capacitor, or a poor solder joint on a tiny crystal package can produce exactly the “works when I touch it” symptom. Several of these are covered in PCB layout mistakes that only show up at assembly.
A short check before you release the board
- Read the oscillator section of the chip’s datasheet and reference manual, and write down the limits on ESR, CL, C0 and drive level.
- Choose a crystal inside those limits, with margin, not at the edge.
- Calculate the capacitor values with a stray estimate, then plan to adjust. Leave footprints for the capacitors even if the part has internal ones.
- Measure the output frequency from a clock-out pin on several boards.
- Start the oscillator repeatedly: cold, after a brown-out, at minimum supply voltage, and across the temperature range the product will see.
- Compare units. A design that works on one board and not another is a marginal design, not a bad board.
How we approach it
We check the crystal, the capacitors and the copper against the chip’s own oscillator documentation, then measure frequency and startup on real boards instead of trusting the schematic. If you have a board with an unreliable clock, send the schematic, layout files and the crystal’s datasheet and we will tell you which of the margins is thin.
If a board's crystal starts on the bench but not reliably across units or temperature, we would review the crystal, capacitors and layout against the chip's oscillator documentation.
Tools for this topic
- PCB trace impedanceTrace width for a target impedance, or the impedance of a width: microstrip and stripline, single or differential pair, with 4-layer stack-up presets.
- Voltage dividerVout from Vin and two resistors, or the best standard pairs for a target Vout — with tolerance range and load effect.
- Regulator feedback resistorsFeedback pairs for any Vref, with the Iadj term for adjustable regulators and divider-current guidance.
Related notes
- Membrane switch overlay design checklistWhat to settle before a membrane switch overlay goes to a fabricator: tail exit, venting, domes, material, shielding and enclosure fit, with reasons.
- I2C bus stuck low after a resetWhy an I2C sensor holds SDA low after the MCU resets, how the nine-clock bus clear works, and the board and firmware changes that prevent a hang.
- Where to put ESD protection on a USB or connector portWhere the TVS diode goes next to the connector, how to ground it with short stitched vias, and what to keep out of the path so a static zap at the connector…