Solve the classic 16 MHz Arduino / AVR 115,200 baud timing error
On an ATmega328P running at 16 MHz, standard 16× oversampling (U2X0 = 0) gives an ideal divisor of 8.6805. Rounding to integer divisor 9 (UBRR0 = 8) produces 111,111 bps—a −3.55% error that drifts 33.7% of a bit by the stop bit and frequently corrupts serial bytes.
Load the U2X=1 preset (8× oversampling) to see divisor 17 (UBRR0 = 16) synthesize 117,647 bps (+2.12% error), which is why the Arduino HardwareSerial core enables U2X0 automatically.
Formulas
UBRR = round(F_osc ÷ (Oversampling × Baud)) − 116× mode: 16,000,000 ÷ (16 × 9) = 111,111 bps (−3.55%)8× mode (U2X=1): 16,000,000 ÷ (8 × 17) = 117,647 bps (+2.12%)
Worked example
At 16 MHz with 16× oversampling, UBRR = 8 yields −3.55% error (Fail). Switching to 8× oversampling (UBRR = 16) drops error to +2.12%, or switching to 57,600 bps (8×) achieves −0.79%.