cancel
Showing results for 
Search instead for 
Did you mean: 

2 PWM outputs synchronize -- not synchronize after 2nd PWM output start

mxo
Associate III

Once I posted the issue about 2 PWM outputs synchronize.

https://community.st.com/t5/stm32-mcus-products/2-pwm-outputs-is-this-possible/td-p/587654 

Now every 1st time after power on (or CPU reset if connected with IDE/Programmer) it works exactlly synchronized, but after 2nd start or afterward slave output timing is randomly skewed with master output.

What's wrong here?

 -TIM2 = master  .. trigger on counter overflow

mxo_0-1694676425819.png

 -TIM3 = slave

mxo_1-1694676567706.png

 -codes

mxo_2-1694676902267.png

I wonder that once timer start synchronous why timing is skewed only by PWM start or stop??

I cannot find difference in dumped registers.. configuration, 1st start, and 2nd start.  ...see attached.

I'm glad to hear someone can advise.
kindly regards

 

1 ACCEPTED SOLUTION

Accepted Solutions

hello @waclawek.jan 

thank you for your advise, and now it was solved.

I used HAL_TIM_PWM_Stop() before, but it reset CR1.CEN I found.

then I modify it not to reset CR1.CEN as followings, and works as well expected.

mxo_0-1695106680734.png

regards.

View solution in original post

5 REPLIES 5
Issamos
Lead II

Hello @mxo 

This tutorial is almost doing the same thing.

Best regards.

II

mxo
Associate III

hello @Issamos 

thanks you for informing, but no hint about my problem is there.

1st time to start synchronizing PWM output is completely works, no doubt.

but problem is after stop PWM output and then restart it.

now I'm trying some TIM initialization made before restart, but still not work as expected.

regards.

mxo
Associate III

represent the problem by diagram. see attached 'diagram1.png'.

 

>>now I'm trying some TIM initialization made before restart, but still not work as expected.

following is one of my trial.

I wonder that the answer is close here but not found now..

 -call "generate event" before PWM start

mxo_0-1694742801379.png

 --> result

mxo_3-1694742951085.png

regards.

I don't know what are you trying to do, but generally, if the slave has slave-mode controller set in Trigger mode, it does nothing more than set TIMx_CR1.CEN when first trigger arrives. In other words, if you set TIMx_CR1.CEN) in software, there's no effect from the trigger.

JW

hello @waclawek.jan 

thank you for your advise, and now it was solved.

I used HAL_TIM_PWM_Stop() before, but it reset CR1.CEN I found.

then I modify it not to reset CR1.CEN as followings, and works as well expected.

mxo_0-1695106680734.png

regards.