cancel
Showing results for 
Search instead for 
Did you mean: 

Asking about implementing and configure two interrupt timers with Hal library

M abouhasem
Associate II
Posted on July 19, 2017 at 10:14

Is it possible to manage two interrupt timers for two timer one act base timer and one worked as a counter if yes how to call different elapsed timer. Call back function

3 REPLIES 3
Posted on July 19, 2017 at 22:05

Hello!!!

I Don't know what your harware is.

The callback function called automaticaly after you start the timer by call  HAL_TIM_Base_Start_IT(...)

To distinguish interrupts between different timers you can use some code like this.

HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)

{

     if(htim->Instance==TIM2)

         {

             //Do something .The interrupt is from Timer 2

         }

    

      if(htim->Instance==TIM3)

         {

             //Do something else The interrupt is from Timer 3

         }

//...etc

// Don't use 'else' statement because you may lose some 'simultaneous' interrupt from another timer

}

Posted on July 21, 2017 at 13:16

thanks it is working 

Posted on July 21, 2017 at 17:00

M abouhasem wrote:

thanks it is working 

https://community.st.com/0D50X00009bMM5DSAW