2017-12-11 10:19 AM
Hi,
Can I set these Timer registers on the flight without a reset? I need to implement a feature where the timer frequency and PWM duty cycle will change
continuously so it helps it I can change them without having to do a reset.
TIMx->PSC (timer prescaler)
TIMx->ARR (timer autoreload value)
TIMx->CCR1 (PWM duty cycle)
Once I program these registers, do I need to program any other register for these to take affect?
Or these values take affect automatically?
Thanks.
2017-12-11 11:54 AM
PSC gets loaded to the real prescaler only upon Update event (i.e. 'counter rollover').
ARR applies immediately if TIMx_CR1.ARR=0; otherwise again only at Update event.
CCR1 applies immediately if if TIMx_CCMR1.OC1PE = 0 (and of course if channel 1 is not set to input capture) - again, if preload is enabled, the copy happens at Update event.
Update event can be forced by writing one to TIMx_EGR.UG.
I'd recommend you to read thoroughly the timer chapter in RM.
JW