How can I synchronize three timers of STM32F446RE board in StmCubeMX timer setting so that the pulses are in phase?

9 views (last 30 days)
I am using STM32F446RE board, and upon lauching the project in CubeMX from MATLAB, The settings are : I have kept the clock frequency as 90MHz and 10% duty cycle for TIM1, TIM2, TIM3. So it gives same output freuency 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!

Answers (1)

Pratyush
Pratyush on 8 Jul 2024
Hi Pooja,
To ensure that all three PWM signals are in phase on your STM32F446RE board, you need to synchronize the timers. You can follow these steps:
  • Ensure TIM1, TIM2, and TIM3 have the same prescaler, period, and duty cycle in STM32CubeMX.
  • Designate TIM1 as the master and TIM2, TIM3 as slaves.
  • Set the clock source to "Internal Clock".
  • Enable "Master/Slave Mode".
  • Set "Trigger Output (TRGO)" to "Update Event".
  • Set the clock source to "Internal Clock".
  • Set "Slave Mode" to "Trigger Mode".
  • Set "Trigger Input" to "ITR0" (corresponding to TIM1).
  • Generate Code in STM32CubeMX.
  • Initialize TIM1 first, followed by TIM2 and TIM3 in your main.c.
Hope this helps.

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!