{"record":{"id":"ae154f98c1fef551","repo":"embassy-rs/embassy","slug":"msix-auto-calibration-is-enabled-for-a-source-that-ae154f","errorCode":null,"errorMessage":"MSIx auto-calibration is enabled for a source that has not been configured.","messagePattern":"MSIx auto-calibration is enabled for a source that has not been configured\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/rcc/u5.rs","lineNumber":234,"sourceCode":"\n        // Expect less than +/- 5% deviation for LSE frequency\n        if (31_100..=34_400).contains(&lse_config.frequency.0) {\n            // 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","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/rcc/u5.rs#L216-L252","documentation":"embassy-stm32's STM32U5 RCC init throws this when an MSI auto-calibration source (MSIS or MSIK) is marked enabled, but the match over (source, LSE state, enable flag) falls into the catch-all arm — i.e. auto-calibration is switched on without the required prerequisite configuration (typically a configured, valid LSE). The driver treats this combination as an improper configuration rather than silently skipping calibration.","triggerScenarios":"rcc init where config.msis or config.msik has auto_calibration set (e.g. MsiAutoCalibration::MSIK) but the LSE branch conditions are not met — usually LSE not configured, or the corresponding MSIK/MSIS source pattern not matching the enabled arms in the match at u5.rs:234.","commonSituations":"Enabling MSI auto-calibration in the RCC config but forgetting to configure LSE; a config copied from a chip family where the enum arms differ; enabling auto-cal on MSIK while only configuring MSIS; board bring-up where the crystal is present but the driver LSE config was left at default.","solutions":["Configure LSE in config.ls.lse before enabling MSI auto-calibration (frequency Hertz(32_768))","If LSE is not available, remove the MsiAutoCalibration setting from msis/msik so the catch-all arm is not reached","Ensure the auto-calibration variant matches the source you actually configured (MSIS vs MSIK)"],"exampleFix":"// before\nlet mut config = Config::default();\nconfig.msik = Some(MsikConfig { range_to_msck: RangeToMsrck::_4mhz, auto_calibration: MsiAutoCalibration::Msik });\n// LSE never configured -> panic\n// after\nlet mut config = Config::default();\nconfig.ls.lse = Some(LseConfig { frequency: Hertz(32_768), .. });\nconfig.msik = Some(MsikConfig { range_to_msck: RangeToMsrck::_4mhz, auto_calibration: MsiAutoCalibration::Msik });","handlingStrategy":"validation","validationCode":"if config.msik.map_or(false, |c| c.auto_calibration == MsiAutoCalibration::Msik)\n    || config.msis.map_or(false, |c| c.auto_calibration != MsiAutoCalibration::None) {\n    assert!(config.ls.lse.is_some(), \"MSI auto-calibration requires LSE to be configured\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure LSE before enabling any MSI auto-calibration","Keep MSIS and MSIK auto-cal settings consistent with what you actually configured","Review the enum arms in the driver for your chip family when porting configs","Default to no auto-calibration until LSE bring-up is verified"],"tags":["rust","embedded","stm32","rcc","clock-config","panic"],"backgroundTag":"missing-required-config-field","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"}