ESP32 80MHz APB UART & RS-485 Baud Clock Divider Calculator

Calculate ESP32 80 MHz APB UART baud rate accuracy for 115200, 460800 and 921600 bps serial and RS-485 Modbus links.

Jump to results

Inputs

MCU clock & divider
Frame & oscillator budget
Crystal ~20–50 ppm; internal RC ~10,000 ppm (1%).

Results

Estimates
Baud rate timing error+0.001%
Actual synthesized baud
115,201.2 bps
Prescaler register
CLKDIV = 694, FRAG = 7
Ideal vs. actual divisor
694.444 → 694.438
Stop-bit worst-case drift
0.09% of 1 bit
Bit / frame duration
8.68 µs / 86.8 µs
Link margin screen
Pass (reliable)
Bit-timing & receiver sampling drift (10-bit frame)
ST D0 D1 D2 D3 D4 D5 D6 D7 SP Ideal center tick (dashed) vs. drifted RX sample dot (amber) Baud error: 0.001% · Stop-bit worst-case drift: 0.09% of 1 bit
Standard baud rates at this clock
Target bpsActual bpsRegisterError %Status
9,6009,600CLKDIV = 8333, FRAG = 5+2.50e-4%Pass (reliable)
19,20019,200.2CLKDIV = 4166, FRAG = 10+1.00e-3%Pass (reliable)
38,40038,400.4CLKDIV = 2083, FRAG = 5+1.00e-3%Pass (reliable)
57,60057,600.6CLKDIV = 1388, FRAG = 14+1.00e-3%Pass (reliable)
115,200115,201.2CLKDIV = 694, FRAG = 7+1.00e-3%Pass (reliable)
230,400230,423CLKDIV = 347, FRAG = 3+0.01%Pass (reliable)
460,800460,929.1CLKDIV = 173, FRAG = 9+0.03%Pass (reliable)
921,600922,190.2CLKDIV = 86, FRAG = 12+0.06%Pass (reliable)

Keep single-side baud error under ±2.0% and total TX+RX stop-bit drift well below 45% of one bit period to prevent UART framing errors.

Verify ESP32 80 MHz APB UART timing across baud rates

ESP32 UART peripherals clock from the 80 MHz APB bus (or 40 MHz XTAL on newer S3/C3 chips) using a fractional clock divider (`UART_CLKDIV_REG`). Even at non-power-of-two rates like 115,200 bps and 921,600 bps, the fractional prescaler holds timing error far below 0.2%.

When pairing ESP32 with an RS-485 Modbus network using 8E1 or 8N2 (11-bit frames), verify both quantization error and total stop-bit drift across the 40 ppm crystal tolerance.

Formulas

  • APB_CLK = 80 MHz; ideal CLKDIV = 80,000,000 ÷ 115,200 = 694.444…
  • ESP-IDF truncates CLKDIV × 16 to 11,111, giving 694 + 7/16
  • 11-bit frame stop-bit sample at 10.5 bit times

Worked example

At 80 MHz APB and 115,200 bps, the programmed divider produces 115,201.2 bps (+0.001% error).

Frequently asked questions

Does ESP32 dynamic frequency scaling (DFS) disturb APB UART baud rate?

Yes—if APB frequency changes during light-sleep power management, use the REF_TICK or XTAL clock source (`UART_SCLK_XTAL`) so baud timing stays locked.

Why does ESP32 ROM boot log print at 74,880 or 115,200 bps?

With a 40 MHz crystal, ESP32 defaults to 115,200 bps at boot; 26 MHz crystal variants scale that default ROM rate down to 74,880 bps.

Does ESP32 hardware support automatic RS-485 RTS direction control?

Yes, ESP-IDF `UART_MODE_RS485_HALF_DUPLEX` toggles the RTS pin automatically around transmitted frames without software timing jitter.