📊 PWM Calculator

Frequency, duty and resolution (bits) trade-offs for timer-generated PWM from a clock.

Timer input clock after any bus prescaler.
Divides the timer clock before counting.
Pick which one drives the other.
Used when solving for frequency.
Used when solving for resolution.
Computes the CCR compare value.

How it works

A PWM signal from a hardware timer counts from 0 to ARR at the prescaled clock rate, so its frequency and resolution are directly linked:

fPWM = ftimer ÷ (prescaler × (ARR + 1))
resolution (bits) = log₂(ARR + 1)

Higher resolution (more duty-cycle steps) needs a larger ARR, which lowers the achievable frequency for a fixed clock — the classic PWM trade-off. The compare value is CCR = round((ARR + 1) × duty / 100).