NewAI Part GeneratorFree to get started
FREE TOOL

UART baud rate calculator

Choose an AVR, an STM32 or a generic UART, and this baud rate calculator gives the register value, the rate it really produces at your clock and the percentage error. The result is rated against the tolerance each manufacturer publishes.

Find
Examples
UART
Hz
baud
%

Optional: clock tolerance and the other end. A 100 ppm crystal is 0.01 %; a ceramic resonator is about 1 % with drift.

UBRR

8

U2X = 0

UBRRnH, UBRRnL
0x00, 0x08
Actual baud rate
111111.1 baud
Error against 115200
-3.55 %
Rating
Marginal good to ±2.0 %, limit ±4.58 %
Bit time
9 µs
Fastest rate at this clock
1000000 baud

⚠ Marginal: 3.55 % uses more than this end’s share. It works only if the other end is accurate and the line is clean.

Double speed (U2X = 1) gets closer: UBRR 16 gives +2.12 %. Double speed halves the samples per bit, so the receiver tolerates less.

±2 % is the data sheet’s recommended receiver error for 8 data and parity bits, assuming transmitter and receiver split the total equally.

Standard baud rates at 16 MHz

BaudUBRRActualErrorRating
24004162398.082-0.08 %Good
48002074807.692+0.16 %Good
96001039615.385+0.16 %Good
144006814492.75+0.64 %Good
192005119230.77+0.16 %Good
288003428571.43-0.79 %Good
384002538461.54+0.16 %Good
576001658823.53+2.12 %Marginal
768001276923.08+0.16 %Good
1152008111111.1-3.55 %Marginal
2304003250000+8.51 %Too far off
25000032500000.00 %Good
50000015000000.00 %Good
1000000010000000.00 %Good

How to calculate baud rate register values for a UART

Divide the clock by the oversampling and the baud rate. An AVR uses UBRR = fOSC ÷ (16 × baud) − 1, so 9600 baud at 16 MHz gives UBRR = 103 and 9,615 baud, an error of +0.16 %. An STM32 uses BRR = fCK ÷ baud, so 115200 baud at 72 MHz gives BRR = 0x0271. Keep the total error across both ends of the link under about 2 %.

Baud rate formula for AVR, STM32 and generic UARTs

A UART divides its clock to get a sample clock a set multiple of the baud rate. Only whole divider steps exist, so most combinations of clock and baud rate land slightly off.

AVR: UBRR = fOSC ÷ (16 × baud) − 1     baud = fOSC ÷ (16 × (UBRR + 1))
fOSC
system clock in Hz
UBRR
baud rate register, 0 to 4095

With the double speed bit U2X = 1, replace 16 with 8.

STM32: baud = fCK ÷ (8 × (2 − OVER8) × USARTDIV)
fCK
clock feeding the USART, in Hz
OVER8
0 for 16× oversampling, 1 for 8×
USARTDIV
divider as a fixed-point number in BRR

With OVER8 = 0, BRR holds 16 × USARTDIV, so BRR = fCK ÷ baud. With OVER8 = 1, the upper 12 bits hold the whole part of USARTDIV, bits 2:0 hold the fraction in eighths, and bit 3 must be kept clear. USARTDIV has to be at least 1.

Generic: baud = fCLK ÷ (S × D)
S
samples per bit, usually 16
D
divisor, with n fractional bits in steps of 1 / 2ⁿ

The error is the actual rate against the one you asked for, as the Microchip data sheet defines it:

Error = (actual baud ÷ target baud − 1) × 100 %

Baud rate calculation examples

Example 1: 9600 baud on an ATmega328P at 16 MHz

UBRR = 16,000,000 ÷ (16 × 9600) − 1 = 103.17, which rounds to 103. The real rate is 16,000,000 ÷ (16 × 104) = 9,615 baud, an error of +0.16 %. That is well inside the recommended range.

Example 2: 115200 baud on the same 16 MHz clock

At normal speed UBRR rounds to 8 and the error is -3.55 %. With U2X set, UBRR = 16 and the error is +2.12 %. Both land outside the data sheet’s recommended range (±2 % at normal speed, ±1.5 % at double speed, 8 data bits), though inside its absolute limits.

Example 3: 115200 baud on an STM32 at 72 MHz

With 16× oversampling, BRR = 72,000,000 ÷ 115,200 = 625 = 0x0271, so USARTDIV is 39.0625(mantissa 39, fraction 1/16) and the error is zero. A clock of 8 MHz gets USARTDIV 4.3125 and +0.64 %, as RM0090 Table 135 lists.

Example 4: a fractional divider on the RP2040 at 125 MHz

The PL011 UART uses 16× oversampling and a divider with 6 fractional bits. 125 MHz ÷ (16 × 115200) = 67.817, so the integer part is 67 and the fraction is 52/64, giving a divider of 67.8125, 115,207 baud and an error of +0.006 %.

UART baud rate table: UBRR at 16 MHz and 8 MHz

AVR register values and their error for standard baud rates. A dash means the rate is above what the clock reaches. For other clocks, use the AVR baud rate calculator above.

Baud16 MHz, U2X = 016 MHz, U2X = 18 MHz, U2X = 08 MHz, U2X = 1
2,400416 (-0.08 %)832 (+0.04 %)207 (+0.16 %)416 (-0.08 %)
4,800207 (+0.16 %)416 (-0.08 %)103 (+0.16 %)207 (+0.16 %)
9,600103 (+0.16 %)207 (+0.16 %)51 (+0.16 %)103 (+0.16 %)
19,20051 (+0.16 %)103 (+0.16 %)25 (+0.16 %)51 (+0.16 %)
38,40025 (+0.16 %)51 (+0.16 %)12 (+0.16 %)25 (+0.16 %)
57,60016 (+2.12 %)34 (-0.79 %)8 (-3.55 %)16 (+2.12 %)
115,2008 (-3.55 %)16 (+2.12 %)3 (+8.51 %)8 (-3.55 %)
230,4003 (+8.51 %)8 (-3.55 %)1 (+8.51 %)3 (+8.51 %)
250,0003 (0.00 %)7 (0.00 %)1 (0.00 %)3 (0.00 %)
500,0001 (0.00 %)3 (0.00 %)0 (0.00 %)1 (0.00 %)
1,000,0000 (0.00 %)1 (0.00 %)–0 (0.00 %)

STM32 BRR baud rate table, 16× oversampling

BRR and error for clocks an STM32 commonly feeds its USART. For another clock or 8× oversampling, use the STM32 baud rate calculator above.

Baud72 MHz48 MHz42 MHz16 MHz
9,6000x1D4C (0.00 %)0x1388 (0.00 %)0x1117 (0.00 %)0x0683 (-0.02 %)
19,2000x0EA6 (0.00 %)0x09C4 (0.00 %)0x088C (-0.02 %)0x0341 (+0.04 %)
38,4000x0753 (0.00 %)0x04E2 (0.00 %)0x0446 (-0.02 %)0x01A1 (-0.08 %)
57,6000x04E2 (0.00 %)0x0341 (+0.04 %)0x02D9 (+0.02 %)0x0116 (-0.08 %)
115,2000x0271 (0.00 %)0x01A1 (-0.08 %)0x016D (-0.11 %)0x008B (-0.08 %)
230,4000x0139 (-0.16 %)0x00D0 (+0.16 %)0x00B6 (+0.16 %)0x0045 (+0.64 %)
460,8000x009C (+0.16 %)0x0068 (+0.16 %)0x005B (+0.16 %)0x0023 (-0.79 %)
921,6000x004E (+0.16 %)0x0034 (+0.16 %)0x002E (-0.93 %)0x0011 (+2.12 %)

UART baud rate tolerance: how much error a receiver can take

A receiver lines up on the falling edge of the start bit and samples the middle of each bit after that, so the timing error builds up across the frame and is worst at the stop bit. The error budget is shared by both ends of the link.

ATmega328P, from the equations in section 20.8.3. D is data plus parity bits. Recommended values assume the transmitter and receiver split the total equally. For D = 8 at normal speed the data sheet prints −4.54 %, but its own Rslow of 95.36 % gives the −4.64 % shown here.

DU2X = 0 limitRecommendedU2X = 1 limitRecommended
5+6.67 / −6.80 %±3 %+5.66 / −5.88 %±2.5 %
6+5.79 / −5.88 %±2.5 %+4.92 / −5.08 %±2 %
7+5.11 / −5.19 %±2 %+4.35 / −4.48 %±1.5 %
8+4.58 / −4.64 %±2 %+3.90 / −4.00 %±1.5 %
9+4.14 / −4.19 %±1.5 %+3.53 / −3.61 %±1.5 %
10+3.78 / −3.83 %±1.5 %+3.23 / −3.30 %±1 %

STM32F4 receiver tolerance from RM0090 Tables 145 and 146, with three-sample voting (ONEBIT = 0):

FrameDivider16× oversampling8× oversampling
8-bit (M = 0)integer (fraction 0)±3.75 %±2.5 %
8-bit (M = 0)fractional±3.33 %±2 %
9-bit (M = 1)integer (fraction 0)±3.41 %±2.27 %
9-bit (M = 1)fractional±3.03 %±1.82 %

Those figures cover everything: transmitter error, receiver divider error, receiver clock and line asymmetry together. Maxim’s AN2141 reaches a similar general result for a 16× UART sending 8N1: ±2 % total on a long capacitive line and ±3.3 % on a short clean link.

Keeping a UART link reliable

Count the clock source in the budget, not just the divider. A 100 ppm crystal is negligible, a ceramic resonator can use up about 1 % once drift is included, and an internal RC oscillator needs checking against its data sheet. Enter these in the baud calculator’s “Other error to include” field. The divider error and the clock tolerance add, and the other device contributes its own share. If the error is too high, pick a clock that divides exactly, turn on a fractional divider, or use a lower baud rate. On STM32, make sure you use the clock feeding that USART: on STM32F4, USART1 and USART6 run from PCLK2 and the others from PCLK1.

Glossary

Baud rate
Symbols per second. On a UART each symbol is one bit, so this equals bits per second.
UBRR
The AVR USART baud rate register, 12 bits wide.
BRR
The STM32 USART baud rate register, holding USARTDIV as a fixed-point number.
USARTDIV
The STM32 baud rate divider: 12 mantissa bits and 4 (or 3) fraction bits.
Oversampling
How many clock ticks the receiver takes per bit to find its center, usually 16 or 8.
U2X
The AVR double speed bit, which changes the divider from 16 to 8.
8N1
A frame of one start bit, 8 data bits, no parity and one stop bit.

Related guides

Frequently asked questions

What is the UART baud rate formula?

Baud = clock ÷ (oversampling × divider). On an AVR at normal speed that is fOSC ÷ (16 × (UBRR + 1)), with 8 instead of 16 when U2X is set; on an STM32 it is fCK ÷ (8 × (2 − OVER8) × USARTDIV); and on a generic UART it is fCLK ÷ (S × D).

Baud rate vs bit rate: are they the same on a UART?

On a UART, yes. Baud rate counts symbols per second, bit rate counts bits per second, and each UART symbol is one bit, so the two numbers are equal.

What is the formula for the AVR baud rate register?

UBRR = fOSC ÷ (16 × baud) − 1, rounded to the nearest whole number. With the double speed bit U2X set, use 8 instead of 16. The actual rate is then fOSC ÷ (16 × (UBRR + 1)).

What baud rate error is acceptable for a UART?

A common rule is ±2 %. The whole link, both clocks included, typically has to stay within about ±2 % on a long or capacitive line and ±3.3 % on a short clean one. The ATmega328P data sheet recommends at most ±2 % receiver error for 8 data bits at normal speed.

What UBRR do I use for 9600 baud at 16 MHz?

UBRR = 103, which gives 9,615 baud, an error of +0.16 %. For other clocks and rates, use the UBRR calculator at the top of this page.

Why is 115200 baud unreliable on a 16 MHz Arduino?

A 16 MHz clock does not divide evenly. At normal speed, UBRR 8 gives -3.55 %; with U2X, UBRR 16 gives +2.12 %. Both are outside the data sheet’s recommended range, so the link depends on the other end being accurate.

How do I calculate the STM32 BRR value?

BRR = fCK ÷ baud with 16× oversampling, rounded to a whole number. At 72 MHz and 115200 baud that is 625 (0x0271), or USARTDIV 39.0625. With 8× oversampling the top bits are the mantissa and bits 2:0 are the fraction in eighths, and bit 3 stays clear.

What is the difference between 16× and 8× oversampling?

Dividing by 8 doubles the maximum baud rate, from fCK ÷ 16 to fCK ÷ 8, but the receiver takes half as many samples per bit, so it tolerates less clock error. RM0090 lists 3.33 % at 16× and 2 % at 8× for 8-bit frames with a fractional divider.

Which crystal frequencies give zero baud rate error?

Multiples of 1.8432 MHz, such as 3.6864, 7.3728, 11.0592, 14.7456 and 18.432 MHz, divide exactly to the standard rates. The ATmega328P data sheet tables show 0.0 % at those clocks for most rates.

More free PCB tools

See all free electronics tools →

Sources

Design the whole board, not one number

ProtoFlow is free AI PCB design software: describe a circuit and get a schematic with real parts, PCB layout with an autorouter, SPICE simulation and Gerber files. Native KiCad, Altium and EAGLE import and export. Free on macOS, Windows and Linux.

Get for Mac

Free to start. No card required.