Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 295 of 9364. Peripheral Interfacing and ControlFree lesson

Utilizing Center-Aligned PWM for Reduced Electromagnetic Interference

Learners will configure timers for center-aligned mode to generate symmetrical pulses that lower switching noise in sensitive electronic environments.

In this lesson, you will learn how to configure your hardware timers into center-aligned mode to generate symmetrical PWM signals that significantly reduce electromagnetic interference (EMI).

Why Edge-Aligned PWM Creates Noise

Up until now, we have used edge-aligned PWM. In this mode, the timer counts from 0 to a maximum value, resets, and starts over. Because the PWM pulse always starts at the same moment (when the counter resets), all your switching edges occur at a single, precise frequency spike. When driving high-current loads like motors, this synchronized switching creates a massive surge of current demand at the exact same instant, causing significant electromagnetic noise that can interfere with sensitive sensors or communication lines.

The Mechanics of Center-Aligned PWM

Center-aligned mode changes the way the timer counts. Instead of resetting to zero, the timer counts up to the period value and then counts back down to zero. Imagine the timer acting like a swinging pendulum. Because the counter moves up and then down, the signal turns "on" and "off" symmetrically around the center of the pulse.

By shifting the switching edges to occur at different times relative to each other, you spread the energy of the switching spikes across a broader frequency spectrum. This "smearing" of the noise effectively lowers the peak intensity of the interference, making your circuit much quieter and more robust.

Implementation Concept

To configure this, you modify the timer’s control registers to switch from "Up-counter" to "Center-aligned" mode. In your configuration, it looks conceptually like this:

// Configure the timer mode for center-alignment
// This shifts the compare match events to occur on both up and down counts
TIMER_SetAlignmentMode(TIMER_CENTERALIGNED_MODE_1); 

// The duty cycle remains the same, but switching happens twice per cycle
// This naturally spreads the EMI peaks
TIMER_SetCompareValue(CH1, calculated_pulse_width);

By switching to center-aligned mode, your hardware spends less time dealing with the violent current spikes associated with simultaneous edge transitions, allowing for a cleaner electrical environment for your embedded system.

Key Takeaway: Center-aligned PWM reduces electromagnetic interference by distributing switching transitions symmetrically, which prevents high-current surges from stacking at a single point in time.