tools

Timer / PWM Calculator

Prescaler, period and compare values for a PWM frequency and duty cycle on STM32, AVR and RP2040/RP2350.

[loading tool…]

How it works

Timer Frequency Notes
STM32 TIMx, edge-aligned f = fclk / ((PSC + 1)(ARR + 1)) duty = CCR / (ARR + 1)
STM32 TIMx, center-aligned f = fclk / (2 (PSC + 1) ARR) symmetric PWM for motor control
AVR Timer1, fast PWM (mode 14) f = F / (N (1 + ICR1)) N ∈ {1, 8, 64, 256, 1024}
RP2040 / RP2350 slice f = clk_sys / (DIV × (TOP + 1)) DIV = INT + FRAC/16, phase-correct halves f

The search prefers the smallest prescaler that reaches the frequency exactly, which gives the largest period and so the finest duty-cycle resolution. The result shows how many duty steps you get and the equivalent bits.

Which clock?

On STM32, the timer clock is the APB clock, doubled when the APB prescaler isn’t 1. On the N6 and H7 it can also come from a dedicated kernel clock. Read the exact value from CubeMX’s clock tree; the presets are examples.

References

esc
All tools
ADC / DAC Resolution Calculator[embedded]
Base64 Encoder / Decoder[dev]
Battery Runtime Calculator[hardware]
Chmod Calculator[dev]
CRC Calculator[embedded]
Cron Expression Builder[dev]
CSV ⇄ JSON Converter[dev]
Duty-Cycle Battery Life[embedded]
Generator Wattage Calculator[hardware]
Hash Generator[dev]
HTML Entity Encoder[dev]
JSON Formatter & Validator[dev]
JSONPath Tester[dev]
JWT Decoder[dev]
LED Resistor Calculator[embedded]
LLM Memory / VRAM Estimator[ai]
Lorem Ipsum Generator[text]
Markdown Preview[text]
Markdown Table Generator[text]
Number & Float Inspector[embedded]
Number to Words[text]
Ohm's Law Calculator[embedded]
Password Generator[dev]
Quantization Size Calculator[ai]
RC / LC Filter Calculator[embedded]
Regex Tester[dev]
Register / Bitfield Viewer[embedded]
Resistor Color Code[embedded]
Roman Numeral Converter[text]
Solar Battery Bank Sizing[hardware]
Solar Panel Output[hardware]
SQL Formatter[dev]
Subnet / CIDR Calculator[dev]
Tensor Shape Calculator[ai]
Timer / PWM Calculator[embedded]
UART Baud Rate Error[embedded]
Unix Timestamp Converter[dev]
UPS Runtime Calculator[hardware]
URL Encoder & Parser[dev]
UUID Generator & Inspector[dev]
Voltage Divider Calculator[embedded]
Voltage Drop Calculator[hardware]
Wire Size Calculator[hardware]
XML Formatter[dev]
YAML Validator & Converter[dev]
Commands
Toggle theme (auto → light → dark)
Copy link to this page
Go to all tools
Lire en français
↑↓ move↵ open⌘↵ new tab