embassy-rs/embassy · error
baudrate is not permitted in this mode
Error message
{} baudrate is not permitted in this mode What it means
`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`.
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
Example fix
// before
let mut usart = Usart::new(usart, tx, rx, &config{ mode, baudrate: 115_200, .. });
// after
let mut usart = Usart::new(usart, tx, rx, &Config { mode, baudrate: 1_000_000, .. }); // a supported rate for this mode
Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_BAUDRATES: &[u32] = &[/* rates supported by the selected mode */];
fn baudrate_supported(mode: Mode, baudrate: u32) -> bool {
SUPPORTED_BAUDRATES.contains(&baudrate) // restrict further by mode if needed
}
Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- The top value cannot be changed after the initialization.
- unrecognized rx error
- Can only take the executor once
- Invalid FilterConfig (TooManyFilters)! A FilterConfig must…
- Invalid FilterConfig (EmptyFilterConfig)! A FilterConfig…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/b35bda64c48e8442.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-nxp/src/usart/lpc55.rs:525
SYSCON
.fcclksel(T::instance_number())
.modify(|w| w.set_sel(syscon::vals::FcclkselSel::Enum0x3)); // 96 MHz
96_000_000
}
1501..=750_000 => {
SYSCON
.fcclksel(T::instance_number())
.modify(|w| w.set_sel(syscon::vals::FcclkselSel::Enum0x2)); // 12 MHz
12_000_000
}
121..=1500 => {
SYSCON
.fcclksel(T::instance_number())
.modify(|w| w.set_sel(syscon::vals::FcclkselSel::Enum0x4)); // 1 MHz
1_000_000
}
_ => {
panic!("{} baudrate is not permitted in this mode", config.baudrate);
}
};
// Calculate MULT and BRG values based on baudrate
// There are two types of dividers: integer divider (baud rate generator register and oversample selection value)
// and fractional divider (fractional rate divider).
// For oversampling, the default is industry standard 16x oversampling, i.e. OSRVAL = 15
// The formulas are:
// FLCK = (clock selected via FCCLKSEL) / (1 + MULT / DIV)
// DIV is always 256, then:
// FLCK = (clock selected via FCCLKSEL) / (1 + MULT / 256)
// Baud rate = [FCLK / (OSRVAL+1)] / (BRGVAL + 1) =>
// Baud rate = [FCLK / 16] / (BRGVAL + 1)
// There are 2 unknowns: MULT and BRGVAL.View on GitHub (pinned to 463a07b963)