cancel
Showing results for 
Search instead for 
Did you mean: 

Can I write to the TIMx_CNT register during Center-aligned PWM ?

STuser2
Senior III

I am generating a PWM signal using timer1 register and use it in Center aligned mode. I want to to know if i can modify the timer counter register TIMx_CNT register with some "x" value in the timer interrupt instead of resetting it to 0. 

1 ACCEPTED SOLUTION

Accepted Solutions
Gyessine
ST Employee

Hello @STuser2 
It should be possible.
Here is a project that writes the CNT register of TIM6 after the first interrupt occurs to change the period from 10 seconds to 5 seconds.
You can use it as an example.
BR
Gyessine

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

5 REPLIES 5
TDK
Super User

Yes, you can change the CNT register value at any time. It will affect your PWM signal.

If you feel a post has answered your question, please click "Accept as Solution".
Gyessine
ST Employee

Hello @STuser2 
It should be possible.
Here is a project that writes the CNT register of TIM6 after the first interrupt occurs to change the period from 10 seconds to 5 seconds.
You can use it as an example.
BR
Gyessine

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

STuser2
Senior III

Yes i was able to update and get it working but only in the up counting mode not in Center Aligned mode, is there any method i can follow so that the counter counts from some "X" value to ARR and from ARR to "X" value.

 

Could you please provide comment if it is possible in center aligned mode or not? 

Counters cannot count from X to ARR unless X is 0.

If you feel a post has answered your question, please click "Accept as Solution".