UART baud rate error
UART divisor error, fractional quantization and clock tolerances: numerical examples and STM32F4 receiver limits from RM0090.
Baud-generator error must be kept separate from clock tolerances and receiver limits. The UART calculator returns the divisor, actual baud and generation error: checking the link also requires the behaviour of the other endpoint and the line.
How a UART generates the baud
In the model used here the peripheral clock f is divided by oversampling S and divisor d. The ideal divisor d* may not be representable: the register implements d_q instead.
The receiver detects the start and derives sampling instants from its own clock. This is a division model, not a universal register encoding: some peripherals use a d−1 register, prescalers or different generators. The explicit hardware example is the USART in STM32F405/
Why the error appears
With 16 MHz, 115200 baud and S = 16, d* = 8.680555…; rounding to 9 gives 111111.11 baud, an error of −3.549 %. At 9600 baud d* = 104.166666… and d_q = 104 give 9615.38 baud, an error of +0.160 %. The difference comes from divisor quantization, not from a different percentage tolerance of the same oscillator.
Same baud, different clocks
At 115200 baud, S = 16 and exact nominal clocks, the results are as follows. The fractional grid here is fixed at 1/16; the errors are the actual values for each combination, not worst-case bounds:
| Clock | ideal div | integer div | integer baud | integer error | 1/16 div | 1/16 error |
|---|---|---|---|---|---|---|
| 3.6864 MHz | 2.0000 | 2 | 115 200 | 0.000 % | 2.0000 | 0.000 % |
| 8.0000 MHz | 4.3403 | 4 | 125 000 | +8.507 % | 4.3125 | +0.644 % |
| 12.0000 MHz | 6.5104 | 7 | 107 143 | −6.994 % | 6.5000 | +0.160 % |
| 14.7456 MHz | 8.0000 | 8 | 115 200 | 0.000 % | 8.0000 | 0.000 % |
| 16.0000 MHz | 8.6806 | 9 | 111 111 | −3.549 % | 8.6875 | −0.080 % |
| 18.0000 MHz | 9.7656 | 10 | 112 500 | −2.344 % | 9.7500 | +0.160 % |
| 24.0000 MHz | 13.0208 | 13 | 115 385 | +0.160 % | 13.0000 | +0.160 % |
| 25.0000 MHz | 13.5634 | 14 | 111 607 | −3.119 % | 13.5625 | +0.006 % |
| 48.0000 MHz | 26.0417 | 26 | 115 385 | +0.160 % | 26.0625 | −0.080 % |
| 72.0000 MHz | 39.0625 | 39 | 115 385 | +0.160 % | 39.0625 | 0.000 % |
A higher clock makes the worst-case relative quantization error smaller, but the actual error depends on alignment with the grid. At 14.7456 MHz the divisor is exact at this baud; physical clock tolerance still remains.
An illustrative model of drift within a frame
An 8N1 frame has one start bit, eight data bits and one stop bit: n = 10 intervals. A sample at the centre of the last interval falls about n−0.5 periods after the start. With e denoting a small relative difference in bit periods and q a margin reserved for start detection and sampling, a first-order geometrical condition is:
The table uses q = 1/S for one central sample and q = 2/S to require all three central samples to remain within the window. The latter is a sufficient condition in this model, not the exact tolerance of majority voting: two valid samples may suffice. Initial phase, divisor fraction and start logic change the result for a real receiver.
| Format | n bits | 16× (single sample) | 16× (three samples in window) | 8× (single sample) | 8× (three samples in window) |
|---|---|---|---|---|---|
| 7N1 | 9 | 5.15 % | 4.41 % | 4.41 % | 2.94 % |
| 8N1 | 10 | 4.61 % | 3.95 % | 3.95 % | 2.63 % |
| 8N1 + parity | 11 | 4.17 % | 3.57 % | 3.57 % | 2.38 % |
| 9N1 | 11 | 4.17 % | 3.57 % | 3.57 % | 2.38 % |
| 9 bits + parity | 12 | 3.80 % | 3.26 % | 3.26 % | 2.17 % |
The 3.95 % therefore follows from this model for n = 10, S = 16 and q = 2/16. It is not a universal UART specification. For comparison, RM0090 rev. 21, Table 145, gives 3.75 % with M=0, OVER8=0, ONEBIT=0 and zero fraction; Table 146 gives 3.33 % with a nonzero fraction in the same configuration. Use the conditions and exceptions in the device manual.
Where the sample lands, bit by bit
In the same 8N1 model, the last sample’s drift is 9.5|e|, plus q = 0.125 bit:
| Combined error | Drift on the last bit | Plus the start | Sample |
|---|---|---|---|
| 0.5 % | 0.048 bit | 0.172 bit | inside |
| 1.0 % | 0.095 bit | 0.220 bit | inside |
| 2.0 % | 0.190 bit | 0.315 bit | inside |
| 3.0 % | 0.285 bit | 0.410 bit | inside |
| 4.0 % | 0.380 bit | 0.505 bit | outside |
| 5.0 % | 0.475 bit | 0.600 bit | outside |
The model’s threshold is between 3 % and 4 %: at 4 % the sum is 0.505 bit. This does not imply that the first observed error is always a framing error: data, phase, samples and stop checking matter; incorrect bytes can also occur without that flag. A receiver normally resynchronizes at the start of a new valid frame, so within-frame drift does not grow cumulatively with message length. A percentage error alone does not define a random frame-loss probability.
The budget splits between the two ends
At each endpoint, divisor error and clock deviation determine the actual baud. With e_TX and e_RX denoting the overall errors relative to the same nominal baud, the relative baud difference is:
The sign reverses when moving from baud rates to periods; adding magnitudes is only a first-order approximation. Two endpoints at +2 % and −2 % give a maximum ratio difference of 4.082 %, not exactly 4 %. The tool colours (green below 2 %, amber 2–3 %, red above 3 %) are guidance bands for generator error, not link-verification outcomes: green does not guarantee sufficient margin.
| Assumed tolerance at each endpoint | Maximum relative clock difference |
|---|---|
| TCXO ±2.5 ppm | 0.0005 % |
| quartz ±50 ppm | 0.0100 % |
| RC ±1 % | 2.020 % |
| RC ±2 % | 4.082 % |
These are example assumptions, not component specifications. The same relative clock error, with exact generation at both baud rates, cannot by itself explain why 9600 works and 115200 does not. Check divisors, edges, transceivers, noise, loading and software handling too. RM0090 explicitly separates transmitter error, receiver quantization, receiver oscillator error and line asymmetry.
16× versus 8× oversampling
For the STM32F4 USARTs in RM0090, OVER8=0 uses S=16 and OVER8=1 uses S=8; ONEBIT selects a central sample or a three-sample vote. The manual recommends voting in noisy conditions and a single sample on a noise-free line to increase tolerance to clock deviation. Tolerances also depend on M and the divisor fraction.
Generator maxima are f/16 and f/8: with a 48 MHz peripheral clock, 3 and 6 Mbaud respectively, subject to the device’s electrical limits. These facts do not automatically transfer to other UARTs; the preceding geometrical table does not replace the RM0090 tables.
The fractional divisor
In the cited STM32F4 USARTs, USARTDIV has step h = 1/16 with OVER8=0 and h = 1/8 with OVER8=1; in the latter mode DIV_Fraction[3] must remain zero. Here rounding to the nearest point of the 1/16 grid is considered, within the representable range.
At 16 MHz / 115200 baud, d_q = 8 + 11/16 = 8.6875 and the baud is about 115107.91: −0.080 %. To distinguish actual error from its bound, define δ = d_q−d*. The half-step limit applies to the divisor, whereas the baud depends on its inverse:
The expression h/(2d*) is the first-order approximation, not a strict baud-error bound. The bound applies when rounding is not altered by saturation or register constraints. At 48 MHz and S=16:
| Baud | d* | First-order estimate | Magnitude bound | Actual 1/16 error |
|---|---|---|---|---|
| 9600 | 312.5000 | 0.010 % | 0.010 % | 0.000 % |
| 115200 | 26.0417 | 0.120 % | 0.120 % | -0.080 % |
| 460800 | 6.5104 | 0.480 % | 0.482 % | +0.160 % |
| 921600 | 3.2552 | 0.960 % | 0.969 % | +0.160 % |
| 2000000 | 1.5000 | 2.083 % | 2.128 % | 0.000 % |
At 2 Mbaud, divisor 1.5 = 24/16 is exactly representable: quantization error is zero. The 2.128 % bound describes possible grid offsets near divisors this small, not the error of this configuration. For a fixed baud and clock, use the actual error and add physical tolerances; the bound assesses generator resolution.
Choosing the right clock
Clocks such as 14.7456 MHz are useful multiples for serial rates: at S=16 they give integer divisors for 9600, 19200, 38400, 57600, 115200, 230400, 460800 and 921600. This does not mean zero error for every possible baud or absence of oscillator drift. If USB or a PLL constrains the clock, calculate the representable divisors and check the budget at both endpoints.
Limitations
- The tool calculates nominal generator error, not actual clocks, jitter, line asymmetry or an error probability.
- The calculator’s fractional grid is 1/16: actual RM0090 OVER8=1 configuration requires 1/8 and the correct BRR encoding.
- Other peripherals may use different divisors, registers and limits. Check margin against the manuals and datasheets of the devices and transceivers actually used.
References
- STMicroelectronics, RM0090, revision 21, §§30.3.3–30.3.5, Tables 145–146: sampling, fractional generation and tolerances for the cited STM32F4 USARTs.
- Related tool — UART baud error calculator: divisors and nominal errors; the result is not a complete line verification.