2024-02-19 05:29 AM
Solved! Go to Solution.
2024-02-19 08:08 AM
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!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-02-19 08:08 AM
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!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-02-19 11:41 PM
Thank you @Sarra.S
for the clear and detailed explanation.
Regards,
Carlo