STM32H5 - Issue with TIM update event generation forced by software (UG)
I have already seen some old post about this topic, but without a clear explanation and solution.
Hello @CTabo.1,
When you set the update generation (UG) bit, it takes a few clock cycles for the update to be effective (~3 ck_tim cycles)
So, if two consecutive APB accesses are made (which last 2 cycles), the second one can pass before the update.
It is therefore necessary to add 1 delay cycle: in this case, the 2 actions will be simultaneous (update and forcing to writing counter), and writing takes priority.
>> if I add a couple of __NOP() instructions after the UG command, before clearing the UIF, the function works again.
however, it is not recommended to use NOPs as a delay (unpredictable results in duration, the processor may not execute the NOPs), instead, use Data Memory Barrier (DMB), Data Synchronization Barrier (DSB), and Instruction Synchronization Barrier (ISB) instructions.
Hopefully, this simplifies things slightly!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.