Handling Multiple Timer Interrupts with HAL_TIM_PeriodElapsedCallback() in STM32L562CET6
Hello ,
I am working on a project with the STM32L562CET6 microcontroller and have encountered an issue with the timer interrupt callback function.
1. I configured TIM6 as the clock source for the microcontroller. Consequently, the HAL_TIM_PeriodElapsedCallback() function is automatically triggered whenever the TIM6 interrupt occurs.
2. Now, I have configured TIM2 for a different purpose, but I noticed that when the TIM2 interrupt occurs, the same HAL_TIM_PeriodElapsedCallback() is triggered.
Since the HAL_TIM_PeriodElapsedCallback() is defined with the weak attribute, I understand that I can redefine it in my user code. However, this causes conflicts when multiple timers (like TIM6 and TIM2) trigger this callback.
Questions:
1. Is there a way to alias or redirect the HAL_TIM_PeriodElapsedCallback() to separate functions for different timers (e.g., one for TIM6 and another for TIM2)?
2. Is there any other specific callback function available for timers in STM32 HAL that can help separate the interrupt handling for different timers?
3. What is the recommended approach to handle multiple timers efficiently without such conflicts?
Thank you !
