Question
Change Timer PWM Output Pulse On the Fly
Posted on January 28, 2015 at 21:29
Hi,
I have figured out how to change the period of the Timer 3 on the fly by using TIM3->CNT = someNewValue; and it works good. However, the duty cycle requires updating as well, set up originally as PWM pulse (TIM_Pulse) on Output Channel 1. Here is the code, where dutyCycle is a value from 0.1 to 0.5: TIM_OCInitStructure.TIM_Pulse = (uint16_t)(Period * dutyCycle); TIM_OC1Init(TIM3, &TIM_OCInitStructure); I would like to be able to modify a TIMx register directly to do this. I've looked through the manual but did not see what register(s) I would need to write to do this. Any help/suggestions? Or do I have to re-run the configuration completely? Thank you...