Need more understanding about the Timer enabling fn I am changing CNT register of the Timer in order to get a changed time period on the go (for down counting mode), but doing so correctly is getting delayed by one period.
So I am using STM32H725 on which I have Timer 2 (general purpose timer) which is in down counting, one pulse mode with an interrupt which is triggered at underflow.
Once the interrupt is fired, the TIMx_CNT register value is changed and then __HAL_TIM_ENABLE(&htim2) to run the timer with updated time period but what I am observing on the oscilloscope is that this updated time period not at the next timer period but the one next to it.
What would cause such behaviour?
Also, note that the reference manual says that CNT register is not preloaded (see image) which if it was could have explained this behaviour.
Another thing that I did was that I tried enabling the timer and then changing the TIMx_CNT value and then it worked as expected but this has me confused about the working of the timer.