cancel
Showing results for 
Search instead for 
Did you mean: 

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?

hadi_bijari
Associate II

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

6 REPLIES 6

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

thank u;

is this setup available in stm32cubmx

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 Venmo
Up vote any posts that you find helpful, it shows what's working..

Maybe yes, I don't use CubeMX.

JW

thank u;

it seems OK;i will check it

you know i want two PWM that one of them has an Ts/2 delay from another, so they are not inverse of each other