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

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

  1. Enter the peripheral clock (16M = 16 MHz).
  2. Enter the baud rate you want.
  3. Choose 16× or 8× oversampling.
  4. 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:

The calculator gives:

Tips and common mistakes

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.

All engineering calculators