STM32H5 - Issue with TIM update event generation forced by software (UG)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-19 5:29 AM
I have already seen some old post about this topic, but without a clear explanation and solution.
Solved! Go to Solution.
- Labels:
-
STM32H5 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-19 8: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-19 8: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-19 11:41 PM
Thank you @Sarra.S
for the clear and detailed explanation.
Regards,
Carlo
