{"record":{"id":"a7feab8543734e12","repo":"embassy-rs/embassy","slug":"lse-is-not-configured-but-selected-for-time-drive","errorCode":null,"errorMessage":"LSE is not configured, but selected for time_driver!!!","messagePattern":"LSE is not configured, but selected for time_driver!!!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/rcc/mod.rs","lineNumber":696,"sourceCode":"            //\n            // STM32WBA and STM32L4 use per-timer mux enums (Lptim1sel / Lptim2sel)\n            // while other families share a single Lptimsel enum.\n            macro_rules! ensure_lptim_clk {\n                ($field:ident, $Sel:path, $pclk:pat) => {\n                    match config.mux.$field {\n                        $pclk => {\n                            config.mux.$field = <$Sel>::Lsi;\n                            config.ls.lsi = true;\n                        }\n                        <$Sel>::Lsi => {\n                            config.ls.lsi = true;\n                        }\n                        <$Sel>::Hsi => {\n                            config.hsi = true;\n                        }\n                        <$Sel>::Lse => {\n                            if config.ls.lse.is_none() {\n                                panic!(\"LSE is not configured, but selected for time_driver!!!\");\n                            }\n                            #[cfg(any(rcc_l5, rcc_u5, rcc_u3, rcc_wle, rcc_wl5, rcc_wba, rcc_u0))]\n                            if let Some(mut lse_config) = config.ls.lse {\n                                lse_config.peripherals_clocked = true;\n                                config.ls.lse = Some(lse_config);\n                            }\n                        }\n                        #[allow(unreachable_patterns)]\n                        _ => {}\n                    }\n                };\n            }\n\n            #[cfg(time_driver_lptim1)]\n            {\n                #[cfg(not(any(stm32wba, rcc_l4, rcc_l4plus)))]\n                {\n                    use crate::pac::rcc::vals::Lptimsel;","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/rcc/mod.rs#L678-L714","documentation":"embassy-stm32 lets you pick the RTC time-driver clock source in the rcc config. If `time_driver` is `Lse`, the code checks `config.ls.lse` is Some before using it; if LSE was never configured it panics because it cannot drive the timebase from a clock that has not been set up.","triggerScenarios":"Setting `config.rcc.time_driver = TimeDriver::Lse` (macro form `<$Sel>::Lse`) while `config.rcc.ls.lse` is `None` (LSE not configured / not declared), during `init_rcc` invoked by `reinit`.","commonSituations":"Selecting LSE timebase for accurate RTC timing but forgetting `ls: LsConfig { lse: Some(...) }`; board config where the 32.768 kHz crystal was removed or not modeled; migrating configs between chips where LSE defaults differ.","solutions":["Add `ls: LsConfig { lse: Some(LseConfig::default()), ..Default::default() }` to the rcc config so LSE is configured before selection.","Or switch `time_driver` to a source that is configured, e.g. `TimeDriver::Hsi` or `TimeDriver::Default`.","Verify the board actually has an LSE crystal; without it use the internal MSI/HSI as time driver."],"exampleFix":"// before\nrcc: RccConfig { time_driver: TimeDriver::Lse, ..Default::default() },\n// after\nrcc: RccConfig {\n    time_driver: TimeDriver::Lse,\n    ls: LsConfig { lse: Some(LseConfig::default()), ..Default::default() },\n    ..Default::default()\n},","handlingStrategy":"validation","validationCode":"if config.rcc.time_driver == TimeDriver::Lse && config.rcc.ls.lse.is_none() {\n    panic!(\"TimeDriver::Lse requires rcc.ls.lse to be configured\");\n}","typeGuard":"fn lse_time_driver_valid(rcc: &RccConfig) -> bool {\n    rcc.time_driver != TimeDriver::Lse || rcc.ls.lse.is_some()\n}","tryCatchPattern":null,"preventionTips":["Always pair TimeDriver::Lse with an LsConfig containing lse: Some(...).","Verify the target board actually has a 32.768 kHz crystal before choosing LSE.","Centralize rcc config in one board module so time_driver and ls stay consistent."],"tags":["rust","embedded","rcc","lse","time-driver","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"}