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.
2022-06-14 08: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
2022-06-14 02: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
2022-06-14 05: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
2022-06-14 08: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
2022-06-14 08:42 AM
This will do the trick :) Thank you Petr for the help :)
2022-06-15 04:03 AM
Great I am glad that you found it useful. Good luck on your project.