2024-02-22 10:58 PM
I am using STM32F446RE microcontroller and using MATLAB to develop the logic. Upon launching StmCubeMx, I have kept the clock frequency as 90MHz and 10% duty cycle for TIM1, TIM2, TIM3. So, it gives same output frequency of the pulses (PWM_Output.png) from each PWM. Model screenshot is also attached (model.PNG). All 3 timer settings have been kept same as shown in (Timer_setting.PNG). I want all the 3 pulses shall be in phase. How can I achieve that?
Hoping to hear soon!
Thanks in advance!
2024-02-22 11:36 PM
The simplest thing is to:
- set up all three timers completely, but don't enable them yet
- disable interrupts globally
- enable all the timers
- reenable interrupts globally
There may still be a small phase difference, you can compensate for it by setting CNT of each timer to a small value before enabling.
A more rigorous method is to use the master-slave connection of timers, but that's also more complicated.
JW
2024-02-23 09:29 AM
If you need precise synchronisation, use master-slave connection like JW suggest. It is described in Reference manual in "17.3.15 Timer synchronization".
BTW: To generate three PWMs, you can use just one timer.
2024-02-25 06:52 PM
Thanks @@Michal DudkaDudka, I will once go through manual.
And I Want to generate 6 pulses.
2024-02-25 06:56 PM
Thank You JW. I tried this and as you said there is still small phase shift, trying to compensate that.