Skip to main content
Vu.Andy
Associate III
December 11, 2017
Question

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

  • December 11, 2017
  • 1 reply
  • 504 views
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.

    This topic has been closed for replies.

    1 reply

    waclawek.jan
    Super User
    December 11, 2017
    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