UART Baud Rate / BRR Calculator
embedcalc_uart_baudCalculate STM32 USART baud rate settings and error from clock and target baud. Returns BRR register, actual baud, error percent, and frame timing.
Instructions
Compute the STM32 USART BRR register (mantissa + fraction), the actual achieved baud rate, and the baud error for a given peripheral clock — plus frame size/character time for the given format.
Args:
clock_hz (int): USART peripheral clock in Hz (e.g. 72000000).
baud (int): target baud rate (e.g. 115200).
oversampling (8|16, default 16): USART OVER8 setting.
data_bits (5-9, default 8), parity ('none'|'even'|'odd', default 'none'), stop_bits (1|1.5|2, default 1).
Returns (structured): { mantissa, fraction, brr_hex, actual_baud, error_percent, frame_bits, char_time_us }. Rule of thumb: |error| < 2% total link budget; keep your side < 0.5% when possible. Example: 72 MHz, 115200, over16 -> BRR=0x0271 (mantissa 39, fraction 1), 0.00% error.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| baud | Yes | Target baud rate in bit/s | |
| parity | No | Parity | none |
| clock_hz | Yes | USART peripheral clock in Hz | |
| data_bits | No | Data bits per frame | |
| stop_bits | No | Stop bits | |
| oversampling | No | Oversampling (OVER8): 16 or 8 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| brr_hex | Yes | USART_BRR register value | |
| fraction | Yes | ||
| mantissa | Yes | ||
| frame_bits | Yes | start + data + parity + stop bits | |
| actual_baud | Yes | ||
| char_time_us | Yes | Time per character at actual baud | |
| error_percent | Yes |