What is PWM?
PWM (Pulse Width Modulation) controls the average power delivered to a load by switching a digital signal ON and OFF at a fixed frequency while varying the pulse width.
PWM Frequency Formula (Edge-Aligned)
f_PWM = Timer Clock ÷ ((PSC + 1) × (ARR + 1))
PWM Period
T = 1 ÷ f_PWM
Duty Cycle & CCR
Duty Cycle % = (CCR ÷ (ARR + 1)) × 100
Example for STM32
For an STM32 timer running at 72 MHz with PSC = 71 and ARR = 999:
f_PWM = 72,000,000 ÷ ((71 + 1) × (999 + 1)) = 1,000 Hz = 1 kHz
Common PWM Applications
- DC motor speed and direction control
- LED brightness and RGB color mixing
- RC Servo motor control (typically 50 Hz, 1-2 ms pulse)
- SMPS and DC-to-DC converters (Buck / Boost)
- Audio signal synthesis and class-D amplifiers