embassy-rs/embassy · error
LSE frequency more than 5% off from 32.768 kHz, cannot use…
Error message
LSE frequency more than 5% off from 32.768 kHz, cannot use for MSI auto-calibration
What it means
Same guard as the U3 variant, in embassy-stm32's STM32U5 RCC init: MSI auto-calibration against LSE is requested, but the configured LSE frequency deviates more than 5% from the nominal 32.768 kHz. The hardware expects a standard 32.768 kHz reference for trimming MSI, so the driver panics to avoid calibrating MSI to a wrong frequency.
Solutions
- Correct config.ls.lse.frequency to Hertz(32_768) to match the fitted crystal
- Disable MSI auto-calibration on msis/msik if the LSE reference is not ~32.768 kHz
- Double-check the board schematic for the actual LSE crystal value and align the config
Example fix
// before
config.ls.lse = Some(LseConfig { frequency: Hertz(30_000), .. }); // >5% off
config.msisk = ...; // auto-cal enabled
// after
config.ls.lse = Some(LseConfig { frequency: Hertz(32_768), .. });
// keep auto-cal enabled only with a valid 32.768 kHz reference Defensive patterns
Strategy: validation
Validate before calling
if let Some(lse) = &config.ls.lse {
assert!((31_132..=34_406).contains(&lse.frequency.0), "LSE out of 32.768kHz +/-5% band");
} Type guard
fn lse_in_band(freq: Hertz) -> bool {
(31_132..=34_406).contains(&freq.0)
} Prevention
- Use the standard 32.768 kHz crystal value in LseConfig
- Only enable MSI auto-cal with a genuine ~32.768 kHz reference
- Re-verify LSE config after any hardware revision
- Test clock init early in board bring-up
When it happens
Trigger: config.msis or config.msik with auto_calibration enabled and config.ls.lse.frequency outside 32.768 kHz ± 5% (31132–34406 Hz) on an STM32U5 target.
Common situations: Wrong frequency value typed into LseConfig; using a non-32.768 kHz clock into the LSE pins while auto-cal is on; reusing an RCC config from a different board; changing the crystal without updating the frequency field.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- LSE frequency more than 5% off from 32.768 kHz, cannot use…
- MSIx auto-calibration is enabled for a source that has not…
- The LCD driver needs the RTC/LCD clock to be running
- must not select PLL source as DISABLE
- IC source was set to PLL , but it is not currently enabled
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/61da749fe3ad48c8.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-stm32/src/rcc/u5.rs:237
// Check that the calibration is applied to an active clock
match (
config.auto_calibration.base_mode(),
config.msis.is_some(),
config.msik.is_some(),
) {
(MsiAutoCalibration::MSIS, true, _) => {
// MSIS is active and using LSE for auto-calibration
Some(lse_config.frequency)
}
(MsiAutoCalibration::MSIK, _, true) => {
// MSIK is active and using LSE for auto-calibration
Some(lse_config.frequency)
}
// improper configuration
_ => panic!("MSIx auto-calibration is enabled for a source that has not been configured."),
}
} else {
panic!("LSE frequency more than 5% off from 32.768 kHz, cannot use for MSI auto-calibration");
}
} else {
None
};
let mut msis = config.msis.map(|range| {
// Check MSI output per RM0456 § 11.4.10
match config.voltage_range {
VoltageScale::Range4 => {
assert!(msirange_to_hertz(range).0 <= 24_000_000);
}
_ => {}
}
// RM0456 § 11.8.2: spin until MSIS is off or MSIS is ready before setting its range
loop {
let cr = RCC.cr().read();
if cr.msison() == false || cr.msisrdy() == true {View on GitHub (pinned to 463a07b963)