Serial & Framing

UART Baud Rate & Clock Error Calculator

Calculate exact hardware baud divider registers across STM32, AVR, ESP32, nRF52 and RP2040 clocks and catch framing-error mismatches over 2%.

UBRR = round(F_CPU / (16 * baud)) - 1
16.000 MHz
Common: 9600, 57600, 115200, 921600
UBRR (U2X=0)8 (0x008)Exact hardware divider setting
Actual Baud111,111Target: 115,200 bps
Clock Error-3.55%Exceeds 2% framing threshold
Target BaudUBRR (U2X=0)Actual BaudError %8N1 Status
9,600103 (0x067)9,615+0.16%Safe
19,20051 (0x033)19,231+0.16%Safe
38,40025 (0x019)38,462+0.16%Safe
57,60016 (0x010)58,824+2.12%Risk (>2%)
115,2008 (0x008)111,111-3.55%Risk (>2%)
230,4003 (0x003)250,000+8.51%Risk (>2%)
460,8001 (0x001)500,000+8.51%Risk (>2%)
921,6000 (0x000)1,000,000+8.51%Risk (>2%)
1,000,0000 (0x000)1,000,000+0.00%Safe

Why 2% is the practical UART error ceiling

An 8N1 frame runs 10 bit times from the falling edge of the start bit to the middle of the stop bit (9.5 bit periods to the stop-bit sample point). A combined TX + RX clock mismatch above roughly 4.5% pushes the sample point past the stop-bit boundary and raises a Framing Error (FE). Splitting the budget evenly leaves about 2% per side, before subtracting HSI/RC oscillator drift over temperature.

Classic MCU baud pitfalls

TargetFailure modeFix
AVR @ 16 MHz, 115200U2X=0 yields UBRR=8 and -3.55% error (corrupt bytes).Enable U2X=1 (UBRR=16, +2.12%) or use a 14.7456 MHz crystal.
STM32 APB1 vs APB2Passing APB2 clock into an APB1 USART init halves the actual baud rate.Read HAL_RCC_GetPCLK1Freq() for USART2/3/4/5 and PCLK2 for USART1/6.
STM32 OVER8=1Writing raw USARTDIV into BRR[3:0] shifts the fractional nibble.Right-shift bits [3:0] by 1 and clear bit 3 per RM0090 / RM0410.
Internal RC driftFactory HSI can sit 1–2% off over voltage/temperature.Use HSE crystal for ≥230400 bps or enable auto-baud detection.