Works on this device
Baud Rate Calculator
A UART makes its baud rate by dividing a clock by an oversampling of 16 (or 8) and by a whole divisor. This calculator finds the divisor and the register value for a rate, the rate you really get and its error, a table of rates for one clock, and how long a bit and a character take.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this calculator
- Choose what you want: the divisor for a baud rate (or the rate of a register value), a table of rates for one clock, or the bit and frame time.
- Enter the clock of the UART and the baud rate, and choose the oversampling, 16 or 8.
- Under More options, say whether the register holds the divisor or the divisor minus 1, and how wide it is.
- If you know the largest error your link can accept, type it. The tool then says whether each rate is within it.
The formulas
- Baud rate = clock ÷ (oversampling × divisor).
- Exact divisor = clock ÷ (oversampling × baud rate). The register takes a whole number, so the tool tries the two whole numbers next to it and keeps the one with the smaller error. Some registers hold the divisor minus 1 (UBRR of an AVR: UBRR = divisor − 1).
- Error = (rate you get − rate you want) ÷ rate you want × 100%.
- Frame: 1 start bit + data bits + parity bit (if any) + stop bits. Time of one bit = 1 ÷ baud rate; characters per second = baud rate ÷ bits in a frame.
Worked examples
9600 baud from 16 MHz, oversampling 16: the exact divisor is 16,000,000 ÷ (16 × 9600) = 104.17. The divisor 104 (register value 103 for an AVR) gives 9615.4 baud, an error of +0.16%.
115200 baud from 16 MHz: with oversampling 16 the best divisor is 9, which gives 111,111 baud, −3.55%. With oversampling 8 the divisor 17 gives 117,647 baud, +2.12%.
A clock of 11.0592 MHz gives 115200 baud with a divisor of exactly 6, so the error is 0.
9600 baud with 8N1 (8 data bits, no parity, 1 stop bit): 10 bits per character, so 960 characters per second, 104.17 µs per bit and 7,680 bit/s of data.
Limits you should know
- No error limit is built in. How much error a link stands depends on both ends, the frame length and how the receiver samples; the data sheets give it. Many designers keep each end within about 2%, but that is a habit, not a rule.
- Fractional baud rate generators, auto-baud and the exact register layout of each maker are not covered. Check the UART chapter of your data sheet.
- The error of the clock itself (a crystal or an RC oscillator) is not included.
- For other timer settings, see the Timer Frequency Calculator and the Clock Divider Calculator.