{"record":{"id":"61da749fe3ad48c8","repo":"embassy-rs/embassy","slug":"lse-frequency-more-than-5-off-from-32-768-khz-ca-61da74","errorCode":null,"errorMessage":"LSE frequency more than 5% off from 32.768 kHz, cannot use for MSI auto-calibration","messagePattern":"LSE frequency more than 5% off from 32\\.768 kHz, cannot use for MSI auto-calibration","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/rcc/u5.rs","lineNumber":237,"sourceCode":"            // Check that the calibration is applied to an active clock\n            match (\n                config.auto_calibration.base_mode(),\n                config.msis.is_some(),\n                config.msik.is_some(),\n            ) {\n                (MsiAutoCalibration::MSIS, true, _) => {\n                    // MSIS is active and using LSE for auto-calibration\n                    Some(lse_config.frequency)\n                }\n                (MsiAutoCalibration::MSIK, _, true) => {\n                    // MSIK is active and using LSE for auto-calibration\n                    Some(lse_config.frequency)\n                }\n                // improper configuration\n                _ => panic!(\"MSIx auto-calibration is enabled for a source that has not been configured.\"),\n            }\n        } else {\n            panic!(\"LSE frequency more than 5% off from 32.768 kHz, cannot use for MSI auto-calibration\");\n        }\n    } else {\n        None\n    };\n\n    let mut msis = config.msis.map(|range| {\n        // Check MSI output per RM0456 § 11.4.10\n        match config.voltage_range {\n            VoltageScale::Range4 => {\n                assert!(msirange_to_hertz(range).0 <= 24_000_000);\n            }\n            _ => {}\n        }\n\n        // RM0456 § 11.8.2: spin until MSIS is off or MSIS is ready before setting its range\n        loop {\n            let cr = RCC.cr().read();\n            if cr.msison() == false || cr.msisrdy() == true {","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/rcc/u5.rs#L219-L255","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconfig.ls.lse = Some(LseConfig { frequency: Hertz(30_000), .. }); // >5% off\nconfig.msisk = ...; // auto-cal enabled\n// after\nconfig.ls.lse = Some(LseConfig { frequency: Hertz(32_768), .. });\n// keep auto-cal enabled only with a valid 32.768 kHz reference","handlingStrategy":"validation","validationCode":"if let Some(lse) = &config.ls.lse {\n    assert!((31_132..=34_406).contains(&lse.frequency.0), \"LSE out of 32.768kHz +/-5% band\");\n}","typeGuard":"fn lse_in_band(freq: Hertz) -> bool {\n    (31_132..=34_406).contains(&freq.0)\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","embedded","stm32","rcc","clock-config","panic"],"backgroundTag":"invalid-config-value","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}