How to Configure FlexPWM on Teensy 4.1

Motivation and Goal

Teensy 4.1 FlexPWM Module

Fig. 1 - Clock, PWMA signal for 10-step counting, TOP = 5, INIT = -5, VAL1 = 4, VAL2 = -2 and VAL3 = 2
Fig. 2 - Timer clock (1kHz) and PWMA (100Hz).
Fig. 3 - PWMA (blue) and PWMB (yellow).
Fig. 4 - Teensy 4.1 Expansion Board used to manipulate the signals

Sinusoidal Pulse Width Modulation (SPWM)

Fig. 5 - SPWM Comparison: Triangular Wave and Sawtooth Wave

SPWM Code Example

SPWM Results

Fig.8 - Filtered PWMA and filtered PWMB for a pure sine wave reference.
Fig.9 - Filtered PWMA and filtered PWMB for a sinusoidal reference with third harmonic
Fig. 10 - Evolution of pulse width according to the modulating signal.

Observations and Recommendations



References

[1] i.MX RT1060 Processor Reference Manual, Rev. 3, 07/2021, NXP Semiconductors.

[2] PJRC Electronics Projects - Teensy® 4.1 Development Board