Skip to main content
hadi_bijari
Associate II
November 13, 2019
Question

hello i need 2 PWM from my stm32f407 with 180 degree phase shift. but i cant see this capability in timer block . how can i do this?

  • November 13, 2019
  • 2 replies
  • 1495 views

i think if use master and slave timer can solve this problem but i dont know required configuration in simulink

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
November 13, 2019

I don't know in simulink either, but first, read the TIM chapter in RM, and then

  • set up both timers to PWM as you would normally, with the same period, but don't enable them run
  • one timer will be master, so set up one of its spare channels to PWM with 50% duty (you don't need to assign a real pin to it in GPIO), assign that channel as TRGO source in TIMx_CR2.MMS
  • the other timer will be slave, set up the master's TIM as TRGI source in TIMx_SMCR.TS and set it up for Trigger slave mode in TIMx_SMCR.SMS
  • enable only master timer (by setting TIMx_CR1.CEN)

JW

PS Change your username to a normal nick

hadi_bijari
Associate II
November 13, 2019

thank u;

is this setup available in stm32cubmx

waclawek.jan
Super User
November 13, 2019

Maybe yes, I don't use CubeMX.

JW

Tesla DeLorean
Guru
November 13, 2019

Some TIM have N (negated) channel outputs, ie CH1 and CH1N​.

Others you could use 2 channels, with one in PWM1 mode and the other in PWM2 mode​, here the outputs would be the inverse of each other.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
hadi_bijari
Associate II
November 13, 2019

thank u;

it seems OK;i will check it