{"record":{"id":"80d39f062687e99a","repo":"embassy-rs/embassy","slug":"watchdogchannels-all-is-not-supported-for-awd2-u","errorCode":null,"errorMessage":"WatchdogChannels::All is not supported for AWD2; use Channels(0x3FFF) to monitor all 14 channels","messagePattern":"WatchdogChannels::All is not supported for AWD2; use Channels\\(0x3FFF\\) to monitor all 14 channels","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/adc/watchdog_adc4.rs","lineNumber":284,"sourceCode":"                // CFGR1 fields; setting any bit enables monitoring of that channel.\n                T::regs().awd2cr().modify(|w| {\n                    // Clear all channel bits first, then set the requested ones.\n                    #[cfg(stm32wba)]\n                    {\n                        for n in 0..14usize {\n                            w.set_awd2ch(n, false);\n                        }\n                        match channels {\n                            WatchdogChannels::Single(ch) => w.set_awd2ch(ch as usize, true),\n                            WatchdogChannels::Channels(mask) => {\n                                for n in 0..14usize {\n                                    if mask & (1 << n) != 0 {\n                                        w.set_awd2ch(n, true);\n                                    }\n                                }\n                            }\n                            WatchdogChannels::All => {\n                                panic!(\"WatchdogChannels::All is not supported for AWD2; use Channels(0x3FFF) to monitor all 14 channels\");\n                            }\n                        }\n                    }\n                    #[cfg(stm32u5)]\n                    {\n                        for n in 0..24usize {\n                            w.set_awdch(n, false);\n                        }\n                        match channels {\n                            WatchdogChannels::Single(ch) => w.set_awdch(ch as usize, true),\n                            WatchdogChannels::Channels(mask) => {\n                                for n in 0..24usize {\n                                    if mask & (1 << n) != 0 {\n                                        w.set_awdch(n, true);\n                                    }\n                                }\n                            }\n                            WatchdogChannels::All => {","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/adc/watchdog_adc4.rs#L266-L302","documentation":"The AWD2 analog watchdog on non-U5 ADC4-family STM32 parts has a channel mask register that cannot express 'all channels' as a single value, so the library refuses WatchdogChannels::All instead of silently monitoring nothing. The developer must pass an explicit Channels bitmask covering the 14 channels (0x3FFF). This is a deliberate fail-fast design decision in embassy-stm32's watchdog setup (setup_awd).","triggerScenarios":"Calling the ADC watchdog API for AWD2 on an ADC4-family (non-stm32u5) chip with WatchdogChannels::All as the monitored-channel configuration, e.g. WatchdogConfig channels field set to WatchdogChannels::All.","commonSituations":"Porting code written for classic bxCAN-era ADC watchdogs where an 'all channels' variant existed; copying an AWD1 configuration to AWD2; enabling a watchdog on all channels by analogy with other HALs.","solutions":["Replace WatchdogChannels::All with WatchdogChannels::Channels(0x3FFF) to explicitly monitor all 14 channels","If fewer channels are actually needed, pass a narrower mask (e.g. Channels(0x0001) for channel 0) to reduce false watchdog trips","Use AWD1 instead of AWD2 if the watchdog must support an 'all channels' mode on this chip family"],"exampleFix":"// before\nlet config = WatchdogConfig { channel: WatchdogChannels::All, .. };\n// after\nlet config = WatchdogConfig { channel: WatchdogChannels::Channels(0x3FFF), .. };","handlingStrategy":"validation","validationCode":"// Rust: const ALL_14: WatchdogChannels = WatchdogChannels::Channels(0x3FFF);\n// Only pass WatchdogChannels::All to AWD1; for AWD2/AWD3 always use Channels(mask).","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use WatchdogChannels::All for AWD2/AWD3 on ADC4-family parts","Centralize watchdog channel constants (0x3FFF / 0xFFFFFF) in one module","Add a compile-time or unit-test check that mapping of watchdog -> channels excludes All"],"tags":["embedded","stm32","adc","watchdog","panic"],"backgroundTag":"unsupported-operation","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"}