How to disable HAL_TIM_PeriodElapsedCallback on a timer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-10 12:57 AM
Hi I would like to know if I can still get the interrupt updates of a timer but disable the call to the callback HAL_TIM_PeriodElapsedCallback.
Solved! Go to Solution.
- Labels:
-
TIM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-14 8:31 AM
You can disable the update interrupt with resetting appropriate bit in DIER register of the timer. For TIM1 it would be something like:
htim1.Instance->DIER&=~(TIM_DIER_UIE);
There is no possibility to tell HAL not use call a callback function, but as I said earlier you can define your own callback function. Can you maybe further describe your use case? Maybe I am not understanding correctly.
Kind regards,
Petr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-14 2:13 AM
Hello RPG,
from your question it is not clear to me what exactly you are trying to achieve. Do you want to call different function intstead of HAL_TIM_PeriodElapsedCallback function? Or do you want to only register different interrupts ie. capture or error interrupts? In stm32fxxx_it.c file you can delete the use of HAL_TIM_IRQHandler and handle the interrupt completely by yourself together with resetting flags. You can also register your own callback functions or you can just disable the update event interrupts. If these possibilities do not answer your question. Please let me know.
With the best regards,
Petr David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-14 5:32 AM
Hi Petr.
​
I can see that HAL_TIM_PeriodElapsedCallback is called from HAL generated code when the HAL_TIM_IRQHandler is called. Just wanted to know I there is a way to prevent HAL to call that callback (not commenting the calling line of the code) by setting a flag or anything else.
Thanks for the help :)
​
Best regards,
​
Raúl Pérez
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-14 8:31 AM
You can disable the update interrupt with resetting appropriate bit in DIER register of the timer. For TIM1 it would be something like:
htim1.Instance->DIER&=~(TIM_DIER_UIE);
There is no possibility to tell HAL not use call a callback function, but as I said earlier you can define your own callback function. Can you maybe further describe your use case? Maybe I am not understanding correctly.
Kind regards,
Petr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-14 8:42 AM
This will do the trick :) Thank you Petr for the help :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-15 4:03 AM
Great I am glad that you found it useful. Good luck on your project.
