Search topics...
Timers & PWMPWM Generationfoundational

What is the difference between center-aligned and edge-aligned PWM?

0 upvotes
Practice with AISoon
Study the fundamentals first — Timers & PWM topic page

In edge-aligned mode, the counter counts up from 0 to ARR, generates an overflow event, resets to 0, and repeats. This produces a sawtooth waveform. PWM transitions happen at two points: the output goes high at counter reset (0) and goes low when the counter reaches CCR. All PWM channels on the timer switch at the same counter-reset instant, creating simultaneous current transients. Edge-aligned is simpler to understand and is the default for most applications — LED dimming, servo control, simple power regulation.

In center-aligned mode, the counter counts up from 0 to ARR, then counts back down from ARR to 0, creating a triangular waveform. PWM transitions happen symmetrically — the output toggles once on the up-count when the counter reaches CCR, and again on the down-count when it passes back through CCR. This produces pulses that are centered within each period. The PWM frequency is halved for the same ARR value because one full up-down cycle takes 2 * ARR clock ticks: f_PWM = f_CLK / ((PSC + 1) * 2 * ARR).

Center-aligned mode is strongly preferred for motor control because the symmetric switching pattern spreads current transients across the period rather than concentrating them at the counter reset. In a 3-phase inverter, this reduces peak current ripple, lowers audible noise, and significantly reduces EMI. It also creates a natural ADC sampling point at the center of the PWM period (counter = 0 or counter = ARR), where the current waveform is at its midpoint and most representative of the average value — this is critical for field-oriented control (FOC) algorithms. The cost is reduced frequency for a given ARR and slightly more complex timing analysis.

Source: Timers & PWM Q&A