8 years, 9 months ago.

Nucleo F401RE- PWM

Hi, I can not fix frequency and duty cycle by " .period() " and ".pulsewidth()" commands anymore. It gives me messed up results, and I can see phase_shift in channels. Do you know how to resolve the phase_shift problem?

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F401RET6 microcontroller.

1 Answer

8 years, 9 months ago.

Against phase shift use PWM units which operate on the same timer (So for example PWM1/1 and PWM1/2).

For your other problem you need to give more information.

It is true. But I need to have two symmetry PWMs (like the pic.) The attached waveforms can be obtained by phase shift also. The problem is channels with the same timer fire at the same time and I can't have phase shift. And if I use different timers, then the waveforms won't be symmetry. /media/uploads/arshamshirkhani/pwm2.png

posted by Arsham Shirkhani 21 Aug 2015

You can use PwmOut to set PWM on for example PWM1/1. Then you can use either ST drivers or direct register manipulation to enable the PWM1/1N output, which can be set to be opposite to PWM1/1.

posted by Erik - 22 Aug 2015