Showing results for 
Search instead for 
Did you mean: 


Associate II

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!




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.


Michal Dudka
Senior III

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.

Thanks @@Michal DudkaDudka, I will once go through manual. 

And I Want to generate 6 pulses.

Thank You JW. I tried this and as you said there is still small phase shift, trying to compensate that.