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
PWM in multiple GPIO ports with phase angle shift
Moderator: Benj
PWM in multiple GPIO ports with phase angle shift
- Attachments
-
- PWM.fcfx
- (10.01 KiB) Downloaded 176 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PWM in multiple GPIO ports with phase angle shift
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?
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.
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?
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: PWM in multiple GPIO ports with phase angle shift
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
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
- Attachments
-
- PWM.fcfx
- (16.52 KiB) Downloaded 192 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: PWM in multiple GPIO ports with phase angle shift
We currently support the RTC in the F303Also is there any external C code to enable the SM32F4x MCU's internal RTC?
I will see if I can get some time to add support for F446
Re: PWM in multiple GPIO ports with phase angle shift
Hi Leigh,
It will be good if you add RTC for F407 series and F447 Series. Thanks.
Palani
It will be good if you add RTC for F407 series and F447 Series. Thanks.
Palani