UART Baud Rate Calculator
Find the closest achievable baud rate and its error for a given clock.
Formula
N = round(Fclk / (samples × baud)) → actual baud = Fclk / (samples × N)
Inputs
- Clock frequency (Hz)
- Desired baud rate (bps)
- Oversampling
What it does
A UART divides its clock by a whole number to make the baud rate, so the real rate is slightly off. This finds the divisor, the actual baud rate and the percentage error.
Where it's used
Setting up serial ports on AVR, STM32, PIC and similar microcontrollers.
How to use it
- Enter the peripheral clock (
16M= 16 MHz). - Enter the baud rate you want.
- Choose 16× or 8× oversampling.
- Check the error is small.
The formula explained
- N
- round(F_clk / (oversampling × baud)) — divisor register value
- Actual baud
- F_clk / (oversampling × N)
- Error
- (actual − desired) / desired
Worked example
115 200 baud from an 8 MHz clock — a classic trap: the nearest divisor gives far more than the ~2 % a link tolerates. Try 9600 baud, or a 7.3728 MHz crystal.
Inputs:
- Clock frequency: 8M Hz
- Desired baud rate: 115200 bps
- Oversampling: 16× (most common)
The calculator gives:
- Result: 125000 bps (actual)
- Divisor (N): 4
- Baud rate error: 8.51%
Tips and common mistakes
- Keep the combined error of both ends under about 2 %.
- “UART-friendly” crystals such as 7.3728 or 11.0592 MHz give 0 % error.
- 8× oversampling reaches higher rates but tolerates less noise.
Questions people ask
Why does 115 200 baud fail with an 8 MHz clock?
With 16× oversampling the divisor should be 8 000 000 / (16 × 115 200) ≈ 4.34, but only whole numbers are possible. 4 gives 125 000 baud, 8.5 % too fast. With 8× oversampling the divisor is 9, giving 111 111 baud — still −3.55 %.
What is the formula?
Baud = clock / (oversampling × divisor). For 9 600 baud from 8 MHz at 16× the divisor is 52, giving 9 615 baud — only 0.16 % off, which works reliably.
Which baud rates are standard?
The common ones are 9 600, 19 200, 38 400, 57 600 and 115 200, with higher rates such as 230 400 and 921 600 on fast links. Both ends must be set to the same rate.
Related Embedded & Comms calculators
Enter your values to get the result with the formula, substituted values and an explanation of each step.