Skip to main content
M abouhasem
Associate II
July 19, 2017
Question

Asking about implementing and configure two interrupt timers with Hal library

  • July 19, 2017
  • 1 reply
  • 3246 views
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

    This topic has been closed for replies.

    1 reply

    Vangelis Fortounas
    Associate II
    July 19, 2017
    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

    }

    M abouhasem
    Associate II
    July 21, 2017
    Posted on July 21, 2017 at 13:16

    thanks it is working 

    Nesrine M_O
    Associate
    July 21, 2017
    Posted on July 21, 2017 at 17:00

    M abouhasem wrote:

    thanks it is working 

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