CubeIDE issue with timers
Hello,
I'm facing a very annoying issue in CubeIDE.
Board: Nucleo-F412ZH.
The project uses TIM1 Channel4 to genrate a Stream of PWM pulses to drive a WS2812B LED strip using DMA.
It also uses TIM9 to generate the systick.
With this configuration, the MCU goes to HardFault in HAL_Init -> HAL_InitTick.
The HardFault is triggered when the SysTicvk interrupt is enabled.
Digging in the code, I found that the guilty code is in the shared interrupt handler.
This handler is invoked by the SysTick interrupt but, due to the interrupt sharing with TIM1 Break interrupt,
the handler call HAL_TIM_IRQHandler for TIM1.
Digging deeper, I found that the code calls a non existing CallBack function (NULL pointer).
At this point of the program, TIM1 is not yet initialized, it will be initialized later in the main function.
Here after are the the guilty parts of the generated code.
If I remove the line HAL_TIM_IRQHandler(&htim1); all run fine.
This issue is not exclusive to the TIM1/TIM9 pairing, it occurs for any pair of timers if they share an interrupt.
______________________________________________________________________
/**
* @brief This function handles TIM1 break interrupt and TIM9 global interrupt.
*/
void TIM1_BRK_TIM9_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_BRK_TIM9_IRQn 0 */
/* USER CODE END TIM1_BRK_TIM9_IRQn 0 */
HAL_TIM_IRQHandler(&htim1);
HAL_TIM_IRQHandler(&htim9);
/* USER CODE BEGIN TIM1_BRK_TIM9_IRQn 1 */
/* USER CODE END TIM1_BRK_TIM9_IRQn 1 */
}
______________________________________________________________________
void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
…
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
htim->IC_CaptureCallback(htim);
#else
______________________________________________________________________
htim1 TIM_HandleTypeDef {...}
…
IC_CaptureCallback void (*)(struct __TIM_HandleTypeDef *) 0x0
