{"record":{"id":"de56eab278125c4c","repo":"embassy-rs/embassy","slug":"radio-sleep-timer-clock-not-configured-radiostsel","errorCode":null,"errorMessage":"Radio sleep timer clock not configured (RADIOSTSEL=DISABLE)","messagePattern":"Radio sleep timer clock not configured \\(RADIOSTSEL=DISABLE\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32-wpan/src/wba/ll_sys_if.rs","lineNumber":410,"sourceCode":"\n    let sleep_accuracy = ll_sys_BLE_sleep_clock_accuracy_selection();\n    let _ = link_layer::ll_intf_le_set_sleep_clock_accuracy(sleep_accuracy);\n}\n\n/// Select the sleep-clock source used by the Link Layer.\n/// Reads the RCC BDCR register to determine which clock source has been\n/// configured for the radio sleep timer and tells the link-layer accordingly.\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn ll_sys_sleep_clock_source_selection() {\n    use embassy_stm32::pac::RCC;\n    use embassy_stm32::pac::rcc::vals::Radiostsel;\n\n    let radiostsel = RCC.bdcr().read().radiostsel();\n    let slp_clk_src = match radiostsel {\n        Radiostsel::Lse => link_layer::_slptmr_src_type_e_RTC_SLPTMR as u8,\n        Radiostsel::Lsi => link_layer::_slptmr_src_type_e_RCO_SLPTMR as u8,\n        Radiostsel::Hse => link_layer::_slptmr_src_type_e_CRYSTAL_OSCILLATOR_SLPTMR as u8,\n        Radiostsel::Disable => panic!(\"Radio sleep timer clock not configured (RADIOSTSEL=DISABLE)\"),\n    };\n\n    let mut frequency: u16 = 0;\n    let _ = link_layer::ll_intf_cmn_le_select_slp_clk_src(slp_clk_src, &mut frequency as *mut u16);\n}\n\n/// Determine the BLE sleep-clock accuracy used by the stack.\n///\n/// Values follow the BLE Sleep Clock Accuracy range encoding used by the\n/// link-layer/HCI (0 = 251-500 ppm ... 7 = 0-20 ppm).\n#[unsafe(no_mangle)]\npub unsafe extern \"C\" fn ll_sys_BLE_sleep_clock_accuracy_selection() -> u8 {\n    use embassy_stm32::pac::RCC;\n    use embassy_stm32::pac::rcc::vals::Radiostsel;\n\n    // BLE SCA range encoding (Bluetooth Core, Vol 6, Part B).\n    const BLE_SCA_251_TO_500_PPM: u8 = 0;\n    const BLE_SCA_021_TO_030_PPM: u8 = 6;","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32-wpan/src/wba/ll_sys_if.rs#L392-L428","documentation":"Before entering low-power sleep, the WBA link layer needs a sleep-timer clock source read from RCC BDCR field RADIOSTSEL. embassy-stm32-wpan maps each valid selection (LSE/LSI/HSE) to the link-layer constant; if RCC reports RADIOSTSEL=DISABLE, there is no sleep clock and ll_sys_sleep_clock_source_selection panics.","triggerScenarios":"Calling ll_sys_config_params or ll_sys_reset (which invoke ll_sys_sleep_clock_source_selection) when RCC.bdcr().radiostsel() reads Disable — i.e. the radio sleep timer clock was never configured in RCC setup.","commonSituations":"Skipping/omitting the RCC configuration snippet for the radio sleep clock when bringing up STM32WBA; resetting BDCR (e.g. after backup-domain reset) leaving RADIOSTSEL at its default; copying init code from a different chip family that lacks the RADIOSTSEL setup.","solutions":["Configure RCC's radio sleep timer clock source (set RADIOSTSEL to LSE, LSI, or HSE) in your RCC init before starting the link layer","Verify the backup domain / LSE oscillator is enabled so BDCR keeps the RADIOSTSEL setting","Check the STM32WBA example RCC init in embassy examples and replicate the radio clock setup"],"exampleFix":"// before (no radio clock configured)\nlet mut config = Config::default();\n// RCC default: RADIOSTSEL = Disable\n// after\nconfig.rcc.radio_sleep_clock = Some(RadioSleepClock {\n    source: RadioSleepClockSource::Lse,\n    // frequency as required for LSE\n});","handlingStrategy":"validation","validationCode":"// before starting the link layer, assert the RCC sleep clock is set:\nlet rcc = unsafe { peris::RCC::steal() };\nassert!(rcc.bdcr().read().radiostsel() != Radiostsel::Disable, \"set radio sleep clock in RCC init\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always configure radio_sleep_clock in RCC config on STM32WBA","Replicate the official example's RCC init","Re-verify BDCR after any backup-domain reset"],"tags":["embedded","rcc","stm32wba","low-power"],"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-23T08:17:48.524Z"}