STM32G474 + FL2400159 a 24 MHz HSE crystals — HAL_RCC_OscConfig always falls into the Error_Handler; I haven’t been able to figure out why
Hi everyone,
I designed a board around the STM32G474 and I'm trying to use an external 24 MHz HSE crystal, but the crystal won't run under any configuration — the generated SystemClock_Config() call to HAL_RCC_OscConfig() returns HAL_ERROR and I land straight in Error_Handler() (infinite while(1) loop).
Crystal I'm using:
- Manufacturer: Diodes Incorporated
- Part Number: FL2400159
- Frequency: 24.0000 MHz
- Package: 3.2 x 2.5 mm, 4-pad ceramic SMD (Saronix-eCera FL series)
- Load Capacitance (CL): 18 pF
- ESR (Equivalent Series Resistance): 30 Ω
- Frequency Tolerance: ±10 ppm
- Frequency Stability: ±15 ppm
- Operating temperature: -40°C ~ +85°C
Load capacitor values I've tried (0603 package, X7R):
- 22 pF
- 12 pF
- 28 pF
Same result with all three: error. Based on the load capacitance formula (Cext = 2×(CL − Cstray), assuming Cstray ≈ 3-5pF), 28pF should be the closest to ideal, but even that didn't work.
What I've checked/done so far:
- CubeIDE → RCC → High Speed Clock (HSE) is set to "Crystal/Ceramic Resonator" (not Bypass)
- Increased HSE Startup Timeout from the default 100ms to 1000ms — still the same error
- Data Cache enabled, Prefetch buffer disabled, Flash latency 4WS — probably unrelated to HSE but listing for completeness
I believe I've set everything correctly on the software/config side, but the crystal either isn't oscillating at all, or HSERDY never sets within the timeout HAL waits for. Could this be a PCB layout issue (grounding, guard ring, trace length), a pin mapping issue, or a problem with the crystal/soldering itself?
I've also attached photos of the schematic and PCB design for you guys to take a look at.





