</>EmbeddedInterview

How does a UART receiver sample bits, and how much baud-rate error is tolerated?

MediumCommunication Protocols

Short answer: The receiver detects the falling edge of the start bit, waits half a bit time to reach its middle (confirming it is still low), then samples each following bit near its centre, typically using 16× (or 8×) oversampling and a majority vote of three samples. Because it resynchronises on every start bit, clock error only accumulates over one frame; for 8N1, the total mismatch between transmitter and receiver must stay below roughly ±4–5%, so each side should be within about ±2%.

Why ~5%: the last sample (the stop bit) is about 9.5 bit-times after the start edge. If it drifts by more than half a bit, it samples the wrong bit: 0.5 / 9.5 ≈ 5.3% total. Edge-detection uncertainty and noise reduce the practical margin to around 3–4.5%, so designers aim for ≤ 2% error per side.

Where baud error comes from

  • Divider rounding: e.g. 16 MHz / (16 × 115200) = 8.68 → divider 9 gives 111,111 baud, −3.5% error. Fractional baud generators or a "UART-friendly" crystal (14.7456 MHz, 18.432 MHz) fix this.
  • Oscillator accuracy: internal RC oscillators can be ±1–3% across temperature, which uses most of the budget; calibrate them or use a crystal for reliable high-baud links.

Oversampling options: 16× gives better noise immunity and timing tolerance; 8× allows higher baud rates from the same clock but tolerates less error.

Auto-baud detection: some UARTs measure the length of the start bit (or of a known character like 0x55 or 0x7F) to set the baud rate automatically, used by MCU ROM bootloaders.

Interview example: "We saw random corrupted bytes at 921600 baud only on hot units; the cause was the internal RC oscillator drifting; switching to the crystal (or lowering the baud rate) fixed it."