Skip to main content
Visitor II
February 23, 2024
Question

TIMER SYSCHRONISATION

  • February 23, 2024
  • 2 replies
  • 1315 views

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!

 

PWM_Output.pngTimer_setting.PNGmodel.PNG

    This topic has been closed for replies.

    2 replies

    Super User
    February 23, 2024

    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

    Visitor II
    February 26, 2024

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

    Graduate II
    February 23, 2024

    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.

    Visitor II
    February 26, 2024

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

    And I Want to generate 6 pulses.