How to restart an STM32 timer halfway with a new value?
I have a timer which at each interrupt first stops itself, and then set its own next delay:
HAL_TIM_Base_Stop_IT(&htim);
// do stuff
__HAL_TIM_SET_PRESCALER(&htim, new_p);
__HAL_TIM_SET_AUTORELOAD(&htim, new_a);
__HAL_TIM_CLEAR_FLAG(&htim, TIM_FLAG_UPDATE);
HAL_TIM_Base_Start_IT(&htim);everything works well. But if I stop the timer before it overflows and interrupts, and then fill it with new values, it keeps finishing its last delay. For example, I stop it a second into a 15-second delay and fill it with values for 1 second delay, after I start it again, it takes ~13 seconds to interrupt instead of 1 second. How can I restart a timer?
