AnsweredAssumed Answered

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

Question asked by Valentin on May 18, 2016
Latest reply on Oct 24, 2016 by Valentin
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!

Outcomes