2020-06-20 12:19 PM
So I adjusted the ARR and Prescalar values to adjust the pwm frequency(20KHz). Timer Clock is 200MHz
I want to change the resolution in the run time with a function. How can I change it?
Changing the ARR value will change the resolution?
Thanks in advance
Solved! Go to Solution.
2020-06-21 11:13 AM
You change the CCRx for the CHannel of the TIM you are outputting too. ie TIM1->CCR2 = 5000; // 50/50 duty on a TIM where ARR=10000-1
You can have 4 PWM channels per TIM. They will share a common FREQUENCY.
2020-06-20 12:46 PM
You mean, changing duty cycle?
That's changed by changing value of TIMx_CCRx.
Read the Timer chapter in Reference Manual.
JW
2020-06-20 11:48 PM
Changing ARR changes the resolution and the frequency at once.
Changing either ARR or CCRx presents a race condition unless you enable the corresponding preload flags.
2020-06-21 10:33 AM
Hey, Thanks for the quick response
I would like to change the duty cycle(0-100%) with a resolution of 0-10000. Please suggest which register to change in the run time
2020-06-21 11:13 AM
You change the CCRx for the CHannel of the TIM you are outputting too. ie TIM1->CCR2 = 5000; // 50/50 duty on a TIM where ARR=10000-1
You can have 4 PWM channels per TIM. They will share a common FREQUENCY.