Crystal Oscillator Not Starting? A Bring-Up Checklist
An MCU crystal that will not start, starts only sometimes or runs off frequency has a short list of causes. Here they are in the order to check them, with worked numbers for a 24 MHz and a 32.768 kHz crystal.
When an MCU crystal will not start, check five things in order: the oscillator configuration in firmware, the load capacitors against the crystal's CL and your stray capacitance, the gain margin, the drive level with any series resistor, and the layout. The Crystal Load Capacitor Calculator does the arithmetic; this checklist gives the order.
The relations come from ST's application note AN2867 (Rev 25, October 2026), its oscillator design guide for STM8 and STM32. The formulas describe the Pierce oscillator in general; the margin of 5, the drive settings and the register and HAL names are ST's.
A worked example: one 24 MHz crystal, three load capacitances
Assume a 24 MHz crystal with an ESR of 60 Ω and a shunt capacitance C0 of 5 pF. These are example values; take yours from the crystal datasheet, and use the maximum ESR, not the typical one. The oscillator must supply at least the critical transconductance gm_crit = 4 × ESR × (2πF)² × (C0 + CL)², and ST asks for five times that.
| Crystal CL | gm_crit | gm for a margin of 5 |
|---|---|---|
| 18 pF | 2.887 mA/V | 14.44 mA/V |
| 10 pF | 1.228 mA/V | 6.14 mA/V |
| 8 pF | 0.9223 mA/V | 4.612 mA/V |
Same frequency, three times the requirement. AN2867 puts the HSE transconductance of STM32 parts in the range of a dozen mA/V, so the 18 pF version asks for more than that, while the 8 pF version has room to spare. The cheapest fix for a marginal oscillator is often a crystal cut for a lower load.
Now the capacitors. Take the 10 pF version with 3 pF of stray capacitance from pins and traces. Equal capacitors give C1 = C2 = 2 × (CL - Cstray) = 14 pF, not a standard value. An example motional capacitance Cm of 10 fF turns each choice into ppm.
| C1 = C2 | Load seen | Frequency error | Clock error a day |
|---|---|---|---|
| 10 pF (equal to CL) | 8 pF | +51.3 ppm (fast) | 4.43 s |
| 12 pF | 9 pF | +23.8 ppm (fast) | 2.06 s |
| 15 pF (nearest E12) | 10.5 pF | -10.8 ppm (slow) | 0.929 s |
| 22 pF | 14 pF | -70.2 ppm (slow) | 6.06 s |
At this load the crystal moves 22.2 ppm per pF. The 22 pF habit copied from an old reference design puts it 70.2 ppm slow. It still starts, so nobody notices until something that depends on the exact frequency, a radio channel or a real-time clock, is measured.
Before you change anything: measure without disturbing it
A scope probe on the crystal pins adds capacitance to the load. It shifts the frequency you want to measure, and on a marginal oscillator it can stop a running crystal or kick a stuck one into starting. Measure a buffered copy instead: route the clock to a clock-output pin (MCO on STM32; on the STM32L4 it can output the HSE or the LSE) and use a frequency counter. For the swing at the crystal itself, AN2867 asks for a probe of no more than 1 pF, and 0.1 pF at the LSE input.
Check 1: the oscillator configuration in firmware
Rule out the cheap causes first. A board that looks dead is often a firmware timeout, not a dead crystal.
- Bypass mode off. HSEBYP (and LSEBYP for the 32.768 kHz oscillator) selects an external clock source, such as an oscillator module. With a crystal it must be clear.
- Ready flag and timeout. The STM32L4 HAL enables the oscillator, then polls HSERDY or LSERDY and returns HAL_TIMEOUT when the wait runs past HSE_STARTUP_TIMEOUT or LSE_STARTUP_TIMEOUT. The STM32CubeL4 template sets 100 ms and 5,000 ms. If your code treats that return value as fatal, a slow crystal looks like a dead board.
- LSE drive setting. Parts with a configurable LSE set the drive in the backup domain (RCC_LSEDRIVE_LOW to RCC_LSEDRIVE_HIGH through __HAL_RCC_LSEDRIVE_CONFIG on the L4). Write access to that domain is denied after reset, so enable it first (HAL_PWR_EnableBkUpAccess). On parts where the gain is only statically modifiable, AN2867 says the LSE must be turned off before the drive changes.
- The right drive for the crystal. AN2867 warns that on STM32F0 and STM32F3 the High drive mode is for 12.5 pF crystals only, to avoid saturating the loop and a start-up failure; with a 6 pF crystal the frequency jitters and the duty cycle can be distorted.
- Neighbouring pins. AN2867 notes that activity on PC13, for example RTC_OUT toggling at 512 Hz or 1 Hz, can disturb the LSE and shift its frequency. Remap RTC_OUT where the part allows it.
Check 2: load capacitors against CL and stray
The crystal sees C1 and C2 in series plus the stray: CL = C1 × C2 / (C1 + C2) + Cstray. CL comes from the crystal datasheet and C1 and C2 are your choice; Cstray comes from your layout, and that guess is the real uncertainty. With the 15 pF pair above, a stray of 4 pF instead of 3 pF puts the crystal at -30.3 ppm, and 2 pF puts it at +11.5 ppm.
So treat the calculated value as a starting point, as AN2867 does: measure the first boards and step the capacitors. Fast means the load is too low, so the capacitors go up; slow means they come down. Wrong capacitors mostly cost accuracy, but AN2867 also names capacitors that are too small or too large, and high ESR, as the usual causes of start-up problems.
Check 3: gain margin, the rule ST sets
Gain margin is the oscillator's transconductance gm divided by gm_crit. The threshold of 5 is ST's rule, from section 3.4 of AN2867, which explains that a ratio just above 1 is not enough because of component tolerances and temperature; other vendors state their own criteria, so use your MCU vendor's. Some STM32 datasheets give gm, others give Gm_crit_max, which AN2867 defines as gm / 5. With Gm_crit_max, the check is simply gm_crit below that figure.
On the bench, AN2867 section 3.8 measures the same thing from the other side. Add resistance in series with the crystal, a step at a time, until the oscillator no longer starts. The smallest added resistance that stops it, R_ADD, gives the safety factor by ST's formula (R_ADD + ESR) / ESR. ST counts the HSE as safe at a factor of 5 or more, and the LSE as safe from 3 and very safe from 5. For the 60 Ω crystal, a factor of 5 means it must still start with 240 Ω added.
Check 4: drive level and the series resistor
Drive level is the power the crystal dissipates, and the crystal datasheet gives a maximum. AN2867 measures it from the peak-to-peak swing at the input capacitor: DL = ESR × (π × F × Ctot)² × Vpp² / 2, with Ctot = C1 + Cstray / 2 + Cprobe. For the 24 MHz example with 15 pF capacitors, 3 pF of stray and a 1 pF probe, 1 V peak to peak gives 52.2 µW and 2 V gives 209 µW. The square on the swing is why the number moves so fast.
If the drive is too high, AN2867 adds a resistor in series with the oscillator output. Its starting estimate is the reactance of C2, 1 / (2πF × C2), which for 24 MHz and 15 pF is 442 Ω, and it says to tune the value with a potentiometer. That resistor counts as ESR in the margin check, and the table shows what it costs.
| Loop resistance | Crystal CL | gm_crit | gm for a margin of 5 |
|---|---|---|---|
| 60 Ω (crystal alone) | 10 pF | 1.228 mA/V | 6.14 mA/V |
| 100 Ω (plus 40 Ω) | 10 pF | 2.047 mA/V | 10.23 mA/V |
| 100 Ω (plus 40 Ω) | 18 pF | 4.812 mA/V | 24.06 mA/V |
| 502 Ω (plus 442 Ω) | 10 pF | 10.27 mA/V | 51.37 mA/V |
The full starting estimate raises gm_crit 8.37 times (502 / 60). That is why AN2867 tells you to recalculate the margin after choosing the resistor, and why it does not recommend an external resistor on the 32 kHz oscillator at all.
Check 5: layout and contamination
AN2867 section 7 lists the layout rules. Each one cuts stray capacitance, noise or leakage.
- Put the crystal as close to the MCU as possible and keep the traces short. Long traces add stray capacitance, pick up noise and can radiate during EMC testing.
- Surround the oscillator connections with a guard ring connected to ground.
- Give the oscillator a local ground plane underneath, connected to the nearest MCU ground, and route every fast signal away from it.
- If the crystal has a metal package, do not connect it to the oscillator ground.
- Clean flux residue after assembly, even with no-clean flux on ultra-low-power designs; leakage can lengthen start-up or prevent it. For humid environments AN2867 recommends conformal coating over the crystal, C1, C2 and the OSC_IN and OSC_OUT traces.
Those rules cost nothing before the board is routed. Our PCB design page covers layout and the review of an existing schematic or layout; for the emissions side of the same traces, see EMC by design.
The 32.768 kHz case
Watch crystals are where the margin runs out. Their ESR is tens of kilohms and the LSE amplifier delivers microamps per volt, not milliamps. Take a crystal with an ESR of 70 kΩ and a C0 of 1.2 pF, example values within the range of the 32.768 kHz crystals AN2867 lists, and compare its gm_crit with the Gm_crit_max that AN2867 Table 5 gives for each LSE drive setting of one large group of STM32 series (G0, G4, L0, L4, L5 and U5 among them).
| Crystal CL | gm_crit | Lowest drive setting that passes |
|---|---|---|
| 6 pF | 0.615 µA/V | Medium low (0.75 µA/V) |
| 7 pF | 0.798 µA/V | Medium high (1.7 µA/V) |
| 9 pF | 1.23 µA/V | Medium high (1.7 µA/V) |
| 12.5 pF | 2.23 µA/V | High (2.7 µA/V) |
The Low setting of that group (0.5 µA/V) passes none of them. A 12.5 pF crystal at a low drive setting is the classic RTC that never starts. A higher load and a higher drive cost current, which is the trade-off AN2867 describes: low-CL crystals for coin-cell designs, 12.5 pF crystals where power allows and noise immunity and low pullability matter more.
Then be patient. AN2867 gives a few milliseconds of start-up for a crystal of a few MHz and 1 to 5 seconds for a 32.768 kHz crystal. The 5,000 ms template timeout sits at the slow end of that range, so an LSE with a thin margin can time out even though the crystal is fine.
From ppm to seconds a day
For a clock that keeps time, seconds are the useful unit. A day has 86,400 seconds, so multiply the error in ppm by 0.0864 to get seconds a day. AN2867's own example: on two 7 pF capacitors, a 5% tolerance moves the load by 0.175 pF, which on a crystal of 45 ppm per pF is 7.875 ppm, or 0.68 seconds a day (ST rounds these to about 7.8 ppm and 0.7 s).
| Error | Clock error a day |
|---|---|
| 1 ppm | 0.0864 s |
| 10 ppm | 0.864 s |
| 20 ppm | 1.73 s |
| 50 ppm | 4.32 s |
The parts of the budget add: AN2867 adds the crystal's own tolerance to the load deviation times the pullability, and temperature comes on top of that.
When to stop and fit an oscillator module
If a lower-CL, lower-ESR crystal and the highest drive setting still do not reach a margin of 5, stop tuning and change the part. AN2867 names MEMS oscillators as a good alternative: no load capacitors, small and low power, compatible with all STM32 MCUs and MPUs except the STM32F1 and STM32L1 series, with the STM32 oscillator configured in bypass mode. That is the one case where HSEBYP or LSEBYP belongs on.
Once the clock is measured and right, the rest of the timing follows from it; the STM32 Timer Calculator turns it into PSC and ARR values for any timer frequency. Our firmware development page covers bring-up on the first boards.
Sources
- ST AN2867, Guidelines for oscillator design on STM8AF/AL/S and STM32 MCUs/MPUs, Rev 25, October 2026: section 3.3 load capacitance, 3.4 gm_crit and the gain margin of 5, 3.5 drive level and the external resistor, 3.6 start-up time, 3.7 pullability, 3.8 safety factor, 4.1 Table 5 LSE drive settings, 4.2 the selection procedure and PPM budget, 7 layout, soldering and PC13, 10 MEMS oscillators.
- STM32L4 HAL RCC driver, stm32l4xx_hal_rcc.c and stm32l4xx_hal_rcc.h: the HSERDY and LSERDY waits, HAL_TIMEOUT, the LSE drive macro and the backup-domain note.
- STM32CubeL4 NUCLEO-L476RG template, stm32l4xx_hal_conf.h: HSE_STARTUP_TIMEOUT 100 ms, LSE_STARTUP_TIMEOUT 5,000 ms.
If a clock on your board still will not behave, book a call for a design review of the oscillator and its layout.
Frequently asked questions
Why does my crystal only start when I touch it with a probe?
Touching the pins adds capacitance and injects noise, and a marginal oscillator can use that kick to start. It means the loop has too little gain for this crystal. Compute the gain margin, include any series resistor in the ESR, and look for flux residue or leakage. A healthy oscillator starts on its own every time.
How do I calculate the gain margin of a crystal oscillator?
Divide the oscillator transconductance gm from the MCU datasheet by the crystal's critical transconductance, gm_crit = 4 × ESR × (2πF)² × (C0 + CL)². ST's AN2867 asks for a ratio above 5. A 24 MHz crystal with 60 Ω ESR, 5 pF C0 and a 10 pF load needs 1.228 mA/V: 6.14 mA/V for a margin of 5.
Does a crystal with a lower load capacitance start more easily?
Yes. The critical transconductance grows with the square of C0 + CL, so the same 24 MHz crystal with 60 Ω ESR needs 2.887 mA/V at an 18 pF load and 0.9223 mA/V at 8 pF, about a third. The price is pullability: a low-CL crystal moves more ppm for each pF of stray capacitance.
How do I choose load capacitors without causing start-up problems?
Start from C1 = C2 = 2 × (CL - Cstray), with your own stray estimate (AN2867's example uses 5 pF), and round to the nearest C0G value. AN2867 lists capacitors that are too small or too large, and high ESR, as the usual causes of start-up problems. Then measure the frequency on a buffered clock output and adjust.
Why does my 32.768 kHz crystal take seconds to start?
A watch crystal has a very high Q and tens of kilohms of ESR, and the low-power oscillator driving it delivers only microamps per volt. AN2867 gives 1 to 5 seconds as the normal start-up time. The 5,000 ms LSE timeout in the STM32CubeL4 template sits at the slow end, so thin margin can trip it.
How many seconds a day is a ppm error?
Multiply the error in ppm by 0.0864: a day has 86,400 seconds, so 1 ppm is 86.4 ms a day. A crystal 20 ppm off drifts 1.73 seconds a day. The -10.8 ppm load error from rounding a 14 pF capacitor up to 15 pF costs 0.929 seconds a day, before temperature and ageing.
How inteRFace R&D can help
Building something hardware-shaped?
We help hardware founders go from sketch to certified product. Bring the spec, or just the idea, to a free 30-minute call with a senior engineer. Prefer email? A senior engineer reads every one.
Related articles
I2C Bus Not Working? Check the Pull-Ups and Rise Time
A flaky I2C bus is often a rise-time problem. Here is how to prove it with a scope, work back to the bus capacitance, count the pull-ups already fitted and pick a value inside the window the specification allows.
Embedded SystemsPWM to Analog Voltage: STM32 Timer and RC Filter Design
A PWM pin and one RC filter make a cheap DAC. Here is the full trade on an STM32G0 at 64 MHz: counts per period, ripple under one count, the settling time that buys, the load, and when a second stage or a real DAC wins.
Embedded SystemsHow to Estimate IoT Battery Life From a Duty Cycle
A worked example for a battery-powered sensor node: list every state with its current and time, sum the charge per reporting cycle, fold it into an average current, then derate the cell, add self-discharge and check the pulse the radio draws.