Page 1 of 1

PWM in multiple GPIO ports with phase angle shift

Posted: Tue Oct 06, 2020 7:02 am
by palanivel
Hi Matrix team,
Currently, I try to make a simulation board using STM32F4 series ARM processor for one of my testing projects. I would like to generate the PWM in 6 GPIO ports,
Port 1 = 0 deg Phase angle
Port 2 = Just invert of Port 1 signal
Port 3 = 120 deg Phase angle
Port 4 = Just invert of Port 3 signal
Port 5 = 240 deg Phase angle
Port 6 = Just invert of Port 5 signal

I use 6 timers to generate the PWM. I try to generate the PWM in two different ports, But port's start's at same time and no any phase difference. Can you please guide how to generate the PWM in diffent Phase angle and how to invert the PWM with respect to other port.

Please support.

Regards,
Palani

Re: PWM in multiple GPIO ports with phase angle shift

Posted: Tue Oct 06, 2020 10:41 am
by Benj
Hello,

Leigh may be able to think of some better ideas but this might help to get you there.

In this example I start PWM1, 2 and 3 with 5ms delay in between and this is very close to the 120 degree phase shift you requested. There may be a way to get more accurate but this should give you a ballpark starting point.

To do the inverted output the chip may have a way of doing this for you, but could you instead use an external inverting buffer IC?
PWM.fcfx
(11.92 KiB) Downloaded 179 times

Another way might be to ditch PWM altogether and use a timer interrupt to do software PWM, this wil give you a lot more control.
Timer_PWM.fcfx
(16.23 KiB) Downloaded 207 times

Re: PWM in multiple GPIO ports with phase angle shift

Posted: Wed Oct 07, 2020 10:47 am
by palanivel
Hi Ben,
Thanks. Your code working fine with 3.333 msec delay between each PWM Enable block. But initially, it is OK. but after some time the Phase shift got changed due to the nS variation (333.3 ns in second delay. but I can't put the same in delay) between the PWM to PWM signal. Is there any other method to set the phase angle? PLease advice.

Attached code is working fine. This code can generate PWM in 6 Independent GPIO. Is there any solution for inverting PWM? External circuit (Invert through Not gate) is not feasible for us. Please advice.

Also is there any external C code to enable the SM32F4x MCU's internal RTC?

Palani

Re: PWM in multiple GPIO ports with phase angle shift

Posted: Wed Oct 07, 2020 4:39 pm
by LeighM
Also is there any external C code to enable the SM32F4x MCU's internal RTC?
We currently support the RTC in the F303
I will see if I can get some time to add support for F446

Re: PWM in multiple GPIO ports with phase angle shift

Posted: Thu Oct 08, 2020 8:08 am
by palanivel
Hi Leigh,
It will be good if you add RTC for F407 series and F447 Series. Thanks.

Palani