cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to reload a running timer

petereckstrand9
Associate II
Posted on February 05, 2014 at 20:31

How do I reload a running downcounting timer? Like this:

TIM_UpdateDisableConfig(TIM2, DISABLE);
TIM_SetCounter(TIM2, period);
TIM_UpdateDisableConfig(TIM2, ENABLE);

?? /Frank
1 REPLY 1
chen
Associate II
Posted on February 07, 2014 at 18:32

Hi

''How do I reload a running downcounting timer?''

You may not have to. It depends on the mode the Timer is in.

The TIMx_ARR register controls the period of the timer.

The TIMx_ARR register is buffered so that it can be written to during operation.

This is controlled in TIMx_SR1

The new value is used on the next TIMx_CNT overflow.

Direction of count does not matter (unless you are trying to change it during operation!).

I am sorry but I do not know how to use the Standard Peripheral Library to do this - I have been working with the Timer registers directly.