embassy-rs/embassy · error

MSIx auto-calibration is enabled for a source that has not…

Error message

MSIx auto-calibration is enabled for a source that has not been configured.

What it means

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.

Solutions

  1. Configure LSE in config.ls.lse before enabling MSI auto-calibration (frequency Hertz(32_768))
  2. If LSE is not available, remove the MsiAutoCalibration setting from msis/msik so the catch-all arm is not reached
  3. Ensure the auto-calibration variant matches the source you actually configured (MSIS vs MSIK)

Example fix

// before
let mut config = Config::default();
config.msik = Some(MsikConfig { range_to_msck: RangeToMsrck::_4mhz, auto_calibration: MsiAutoCalibration::Msik });
// LSE never configured -> panic
// after
let mut config = Config::default();
config.ls.lse = Some(LseConfig { frequency: Hertz(32_768), .. });
config.msik = Some(MsikConfig { range_to_msck: RangeToMsrck::_4mhz, auto_calibration: MsiAutoCalibration::Msik });
Defensive patterns

Strategy: validation

Validate before calling

if config.msik.map_or(false, |c| c.auto_calibration == MsiAutoCalibration::Msik)
    || config.msis.map_or(false, |c| c.auto_calibration != MsiAutoCalibration::None) {
    assert!(config.ls.lse.is_some(), "MSI auto-calibration requires LSE to be configured");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10). Data as JSON: /api/errors/ae154f98c1fef551. Report an issue: GitHub.

Appendix: source

Thrown at embassy-stm32/src/rcc/u5.rs:234

        // Expect less than +/- 5% deviation for LSE frequency
        if (31_100..=34_400).contains(&lse_config.frequency.0) {
            // 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

View on GitHub (pinned to 463a07b963)