cancel
Showing results for 
Search instead for 
Did you mean: 

Can these Timer registers be set on the flight without a reset

Vu.Andy
Associate III
Posted on December 11, 2017 at 19:19

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.

1 REPLY 1
Posted on December 11, 2017 at 20:54

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