Skip to main content
Associate II
September 14, 2023
Solved

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

  • September 14, 2023
  • 3 replies
  • 9932 views

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

 

This topic has been closed for replies.
Best answer by mxo

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.

3 replies

Issamos
Lead III
September 14, 2023

Hello @mxo 

This tutorial is almost doing the same thing.

Best regards.

II

mxoAuthor
Associate II
September 14, 2023

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.

mxoAuthor
Associate II
September 15, 2023

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.

waclawek.jan
Super User
September 15, 2023

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

mxoAuthorBest answer
Associate II
September 19, 2023

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.