embassy-rs/embassy · error

IC1 is not ready to be selected as CPU clock source

Error message

IC1 is not ready to be selected as CPU clock source

What it means

On STM32N6, IC1 can be selected as the CPU clock source, but only if it was enabled. Before the switch, the code checks `ic_enabled(1)`; if IC1 was never configured, its output doesn't exist and the library panics instead of switching to a dead clock.

Solutions

  1. Configure IC1 in the rcc config with a ready source, e.g. `ics: [Some(Ic { source: IcSource::Pll1, ..Default::default() }), ..]`, and enable the referenced PLL.
  2. Or select a directly-ready CPU source (Hsi/Hse/Msi) in `config.cpu`.
  3. Ensure IC1's source oscillator/PLL is ready before init (check its ready flags path).

Example fix

// before
rcc: RccConfig { cpu: CpuClk::Ic1, ..Default::default() }, // ic1 not configured
// after
rcc: RccConfig {
    cpu: CpuClk::Ic1,
    ics: [Some(Ic { source: IcSource::Pll1, div: IcDiv::DIV1 }), ..Default::default()],
    ..Default::default()
},
Defensive patterns

Strategy: validation

Validate before calling

if config.rcc.cpu == CpuClk::Ic1 && config.rcc.ics.get(0).map_or(true, |ic| ic.is_none()) {
    panic!("CpuClk::Ic1 requires IC1 to be configured in rcc.ics");
}

Type guard

fn ic1_configured(rcc: &RccConfig) -> bool {
    rcc.cpu != CpuClk::Ic1 || rcc.ics.first().map_or(false, |ic| ic.is_some())
}

Prevention

When it happens

Trigger: Setting `config.cpu = CpuClk::Ic1` while no IC1 entry is configured/enabled in `config.ics` — IC1 omitted, set to None, or its source PLL not enabled.

Common situations: Selecting Ic1 as cpu clock but forgetting the `ics[0]` entry; IC1 configured against a PLL that isn't enabled so it stays disabled; copy-pasted config missing IC definitions.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at embassy-stm32/src/rcc/n6.rs:358

            debug!("  - APB4");
            w.set_ppre4(config.apb4);
        }
        if config.apb5 > w.ppre5() {
            debug!("  - APB5");
            w.set_ppre5(config.apb5);
        }
        if config.ahb > w.hpre() {
            debug!("  - AHB");
            w.set_hpre(config.ahb);
        }
    });
    // cpuclk
    debug!("configuring cpuclk");
    match config.cpu {
        CpuClk::Hsi if !RCC.sr().read().hsirdy() => panic!("HSI is not ready to be selected as CPU clock source"),
        CpuClk::Msi if !RCC.sr().read().msirdy() => panic!("MSI is not ready to be selected as CPU clock source"),
        CpuClk::Hse if !RCC.sr().read().hserdy() => panic!("HSE is not ready to be selected as CPU clock source"),
        CpuClk::Ic1 if !ic_enabled(1) => panic!("IC1 is not ready to be selected as CPU clock source"),
        _ => {}
    }
    // set source
    let cpusw = Cpusw::from_bits(config.cpu.to_bits());
    RCC.cfgr().modify(|w| w.set_cpusw(cpusw));
    // wait for changes to take effect
    while RCC.cfgr().read().cpusws() != Cpusws::from_bits(config.cpu.to_bits()) {}

    // sysclk
    debug!("configuring sysclk");
    match config.sys {
        SysClk::Hsi if !RCC.sr().read().hsirdy() => panic!("HSI is not ready to be selected as system clock source"),
        SysClk::Msi if !RCC.sr().read().msirdy() => panic!("MSI is not ready to be selected as system clock source"),
        SysClk::Hse if !RCC.sr().read().hserdy() => panic!("HSE is not ready to be selected as system clock source"),
        SysClk::Ic2 if !ic_enabled(2) || !ic_enabled(6) || !ic_enabled(11) => panic!(
            "IC2 is not ready to be selected as system clock source (make sure that IC6 and IC11 were configured as well)"
        ),
        _ => {}

View on GitHub (pinned to 463a07b963)