Skip to main content
raptorhal2
Lead
October 14, 2017
Question

How do I avoid multiple definitions for the HAL_TIM_PeriodElapsedCallback

  • October 14, 2017
  • 3 replies
  • 1520 views
Posted on October 14, 2017 at 23:43

Problem occurs because TIM6 dedicated to incrementing SysTick in stm32l4xx_hal_timebase_tim.c and uses same callback function.

Hal

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    October 14, 2017
    Posted on October 15, 2017 at 01:51

    It is provided as a template, modify the function to check for the htim value, and run your code when appropriate.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    raptorhal2
    Lead
    October 15, 2017
    Posted on October 15, 2017 at 16:14

    Thanks, Clive1. It was much simpler when you knew which timer triggered the interrupt. And you could test for the most critical interrupt event first.

    Hal

    john doe
    Senior III
    October 15, 2017
    Posted on October 15, 2017 at 18:12

    the callback passes you a handle to whichever timer caused the interrupt.

    void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
    {
    if (htim->Instance == TIM6)
    {
    do tim6 stuff
    }
    if (htim->Instance == TIM7)
    {
    do tim7 stuff
    }
    }�?�?�?�?�?�?�?�?�?�?�?�?�?