{"record":{"id":"b35bda64c48e8442","repo":"embassy-rs/embassy","slug":"baudrate-is-not-permitted-in-this-mode","errorCode":null,"errorMessage":"{} baudrate is not permitted in this mode","messagePattern":"(.+?) baudrate is not permitted in this mode","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-nxp/src/usart/lpc55.rs","lineNumber":525,"sourceCode":"                SYSCON\n                    .fcclksel(T::instance_number())\n                    .modify(|w| w.set_sel(syscon::vals::FcclkselSel::Enum0x3)); // 96 MHz\n                96_000_000\n            }\n            1501..=750_000 => {\n                SYSCON\n                    .fcclksel(T::instance_number())\n                    .modify(|w| w.set_sel(syscon::vals::FcclkselSel::Enum0x2)); // 12 MHz\n                12_000_000\n            }\n            121..=1500 => {\n                SYSCON\n                    .fcclksel(T::instance_number())\n                    .modify(|w| w.set_sel(syscon::vals::FcclkselSel::Enum0x4)); // 1 MHz\n                1_000_000\n            }\n            _ => {\n                panic!(\"{} baudrate is not permitted in this mode\", config.baudrate);\n            }\n        };\n        // Calculate MULT and BRG values based on baudrate\n\n        // There are two types of dividers: integer divider (baud rate generator register and oversample selection value)\n        // and fractional divider (fractional rate divider).\n        // For oversampling, the default is industry standard 16x oversampling, i.e. OSRVAL = 15\n\n        // The formulas are:\n\n        // FLCK = (clock selected via FCCLKSEL) / (1 + MULT / DIV)\n        // DIV is always 256, then:\n        // FLCK = (clock selected via FCCLKSEL) / (1 + MULT / 256)\n\n        // Baud rate = [FCLK / (OSRVAL+1)] / (BRGVAL + 1) =>\n        // Baud rate = [FCLK / 16] / (BRGVAL + 1)\n\n        // There are 2 unknowns: MULT and BRGVAL.","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-nxp/src/usart/lpc55.rs#L507-L543","documentation":"`configure_clock` in the LPC55 USART driver only supports a fixed set of baudrates per clock mode; the selected mode's clock source maps to specific baudrate divisors, and any other requested baudrate falls into a catch-all arm that panics. The message includes the offending `config.baudrate`.","triggerScenarios":"Calling `Usart::new`/`configure` with a `config.baudrate` that is not one of the supported values for the chosen clock mode (e.g. requesting 115200 while the mode's FCC clock selection only provides specific rates like 1 MHz source).","commonSituations":"Copying a baudrate from a different MCU's example (115200 is common elsewhere but unsupported in the mode used here); changing the clock mode enum without re-checking which baudrates remain valid; typo'd baudrate values.","solutions":["Change `config.baudrate` to one of the values supported by the selected mode (inspect the match arms above line 525 for the allowed set)","Select a different clock mode whose supported baudrate set includes your target rate","Verify with the LPC55Sxx user manual which FLEXCOMM clock source (FCCLKSEL) supports the desired baud rate","If you need an arbitrary baudrate, configure the fractional divider explicitly or extend the driver's match arms"],"exampleFix":"// before\nlet mut usart = Usart::new(usart, tx, rx, &config{ mode, baudrate: 115_200, .. });\n// after\nlet mut usart = Usart::new(usart, tx, rx, &Config { mode, baudrate: 1_000_000, .. }); // a supported rate for this mode\n","handlingStrategy":"validation","validationCode":"const SUPPORTED_BAUDRATES: &[u32] = &[/* rates supported by the selected mode */];\nfn baudrate_supported(mode: Mode, baudrate: u32) -> bool {\n    SUPPORTED_BAUDRATES.contains(&baudrate) // restrict further by mode if needed\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check baudrate against the LPC55 user manual's FCCLKSEL mode table before configuring","Keep baudrate/mode pairs in a single validated config struct","Add a compile-time or startup assertion for the (mode, baudrate) pair"],"tags":["rust","embedded","uart","lpc55","baudrate","unsupported-value"],"backgroundTag":"invalid-config-value","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"}