EN

UART and baud rate

Baud-rate divisor, error and frame time

In asynchronous serial communication (UART) no clock is sent: transmitter and receiver agree on a speed in baud and each one generates it by dividing its own clock. Since the division is rarely exact, the actual speed deviates a little. If the difference between both ends is too large, the receiver reads the last bits of each byte at the wrong place.

\[ \text{divisor} = \frac{f_{clk}}{k \cdot \text{baud}} \qquad \text{error} = \frac{\text{baud}_{real} - \text{baud}}{\text{baud}} \]

Calculator

Clock and speed
MHz
bit/s
Frame

Common rates with this clock

Green: error up to 1 %. Yellow: up to 2 %, works if the other end is exact. Red: unreliable.

How much error is allowed

The receiver synchronises with the start-bit edge and samples each bit at its centre. With 10 bits per frame, the last one is sampled about 9.5 bits after the edge; if the sum of both ends’ errors exceeds half a bit width over that time (≈ 5 %), the byte is lost. Allowing margin for noise and edge shape, a total error of up to 2 to 3 % is considered safe, i.e. around 1 to 1.5 % at each end.

Baud-rate crystals

With a 16 MHz crystal, 115,200 baud gives a 3.5 % (U2X: 2.1 %) error on an AVR. That is why “baud-rate” crystals exist, such as 1.8432, 7.3728, 11.0592 or 14.7456 MHz: they are exact multiples of 115,200 × 16 and every common rate comes out with zero error. Microcontrollers with fractional divisors solve the problem without changing crystal.

Electrical levels

StandardLevelsDistanceNotes
TTL / CMOS0 V and 3.3 or 5 V; idle highA few centimetres to 1 mThe one at the microcontroller pins
RS-232±3 to ±15 V, inverted: logic 1 is negativeUp to about 15 mNeeds a MAX232 or similar; point to point
RS-485Differential, ±1.5 to ±5 V between A and BUp to 1200 mSeveral nodes on a bus; half-duplex with two wires

Related: RS-485 and CAN buses, crystal oscillator, logic level shifting and parity and CRC.