Chris Collins

Tools · embedded

Microcontroller timing calculator

Baud-rate register values with error for AVR, STM32, and ESP32 UARTs; timer prescaler and period solver; ESP32 LEDC PWM resolution; I²C pull-up sizing with an address directory; and SPI clock dividers.

Added

How to use it

Numbers accept engineering suffixes (16M, 72M, 400k, 100p), and the chips under each field fill in common values.

UART baud

Enter the peripheral clock and the target baud rate. AVR lists UBRR in normal and double speed (U2X) modes, STM32 gives the USARTDIV mantissa and fraction for 16× and 8× oversampling, and ESP32 gives the integer and fractional clock divider. Each shows the actual rate and its error, coloured against the usual ±2 % tolerance (about ±4.5 % in total between two devices), and a register snippet you can copy. A table compares every standard baud rate at that clock, so you can see why 16 MHz AVRs struggle at 115200 and why 14.7456 MHz crystals exist.

Timers

Give the timer clock, the frequency or period you want, and the counter width. The solver tries each prescaler (AVR sets, or a free 16-bit STM32 prescaler) and lists the compare/auto-reload values, with the exact frequency and error. The best choice is highlighted, along with the code to set it.

ESP32 PWM (LEDC)

For a clock (80 MHz APB by default) and a PWM frequency, the tool shows the maximum duty resolution in bits, the divider, and the duty steps. It also lists which frequency and resolution pairs are possible, with matching ledcAttach and ESP-IDF code.

I²C

The pull-up calculator uses the I²C specification: the minimum resistor is set by the sink current at VOL (3 mA, or 20 mA in Fast-mode Plus) and the maximum by the rise time for your bus capacitance. It suggests standard E12 values. The address directory lists about fifty common sensors, displays, and expanders with their selectable addresses. Search by part or by address (0x76) to see what might be on your bus.

SPI

Choose a controller family (AVR, STM32 power-of-two prescalers, ESP32 arbitrary dividers, or RP2040) and a target clock. The tool lists the dividers the hardware supports and picks the fastest clock at or below the target, which is what the peripheral will actually run at.

Choosing the load capacitors for the MCU’s crystal: crystal oscillator.

Sharing

Share link copies a URL that opens this tool with your current settings — every value it remembers between visits, packed into ?s=. Opening a link replaces your saved settings for this tool. You can also write a short link by hand with clk, baud (clock and baud rate for the UART tab), for example /tools/mcu-timing/?clk=16M&baud=115200#uart.

Runs entirely in your browser; nothing you type leaves this page.