Skip to main content
valentin
Associate III
May 17, 2016
Question

[CubeMX BUG/REQUEST] add USER CODE to HAL_TIM_PeriodElapsedCallback if a timer is used for timebase (freertos)

  • May 17, 2016
  • 4 replies
  • 663 views
Posted on May 18, 2016 at 01:20

The title says it all.

I'm using the freertos middleware and configured CubeMX to use tim7 as timebase.

As a result, CubeMX generates the stm32f3xx_hal_timebase_TIM.c file and in there defines the IRQ Callback

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)

{

  HAL_IncTick();

}

This is rather unfortunate, though, as without user code I cannot modify it to use other timers as well.

Suggestion, change it to:

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)

{

/* USER CODE START 1 */

/* USER CODE END 1 */

if (htim->Instance == TIMxx) {

  HAL_IncTick();

}

/* USER CODE START 2 */

/* USER CODE END 2 */

}

And place this at the bottom of the main.c file. Otherwise I cannot include needed headers etc.

NOTE: TIMxx is the timer which was selected as timebase.

Thanks!
    This topic has been closed for replies.

    4 replies

    Walid FTITI_O
    Visitor II
    May 18, 2016
    Posted on May 18, 2016 at 15:53

    Hi Valentin,

    I will communicate your feedback to our CubeMx team .

    -Hannibal-

    valentin
    valentinAuthor
    Associate III
    June 7, 2016
    Posted on June 07, 2016 at 04:41

    Thanks a lot!

    stm32cube-t
    ST Employee
    October 6, 2016
    Posted on October 06, 2016 at 17:22

    Dear Valentin,

    Issue fixed since STM32CubeMX release 4.15.

    Best regards

    valentin
    valentinAuthor
    Associate III
    October 24, 2016
    Posted on October 24, 2016 at 22:35

    Great job!

    Thanks for fixing that!