How it works
Many UARTs, including AVR-based Arduino boards, derive the baud rate by dividing the system clock by 16 (or 8 in double-speed mode) and by an integer register value. Because the divider must be a whole number, some clock and baud combinations can't be hit exactly.
Both ends of a link tolerate only a small mismatch. Keeping the error within about ±2% is a common rule; larger errors cause corrupted characters, especially with long frames.
Divider = round(f_clk / (16 × baud)) − 1
Actual baud = f_clk / (16 × (Divider + 1))
Error = (Actual − Target) / Target
(use 8 instead of 16 in double-speed mode)Worked example
A 16 MHz board at 115,200 baud gives 16,000,000 / (16 × 115,200) = 8.68, so the divider is 8 and the actual rate is 111,111 baud, an error of −3.5%. In double-speed mode the divider is 16, the rate 117,647 baud and the error +2.1%, which works far more reliably.