cancel
Showing results for 
Search instead for 
Did you mean: 

TIM macros

CJaro
Associate

My programming level is initial. Breaks with STM32L432KC.

I would like to use the dynamic change of the TIMx period as soon as the TIMx Interruption from the previous period. How to practically use the _HAL_TIM_SET_AUTOREOLAD macro to load a new value(randdom generated) into ARR. At the same time I would like to do it with two TIM6 and TIM7 with different period values.

Thanks in advance.

1 REPLY 1

If you want to change ARR (i.e. period) "on the fly", in the Update interrupt as you plan, you need to have ARR preload enabled (TIMx_CR1.ARPE=1). That means, that the value you set is not effective immediately, but only after the next Update event. If you would not have preload enabled, then if the new ARR would be smaller than the previous one and the current CNT would be higher then the new ARR, the next update would happen only after the timer overflows over its maximum value (0xFFFF for 16-bit timers).

I don't use Cube.

JW