So ST has found that the TIM1_UP_TIM16_IRQHandler
if firing before the TIM1 peripheral is initialized, which is triggering an access to htim1->Instance
which is null. This could explain why disabling all interrupts around the Init() functions makes the issue go away. They also say this has nothing to do with freeRTOS as they can replicate the issue without enabling it in their project generation. I set a breakpoint on HAL_TIM_IRQHandler(&htim1);
in TIM1_UP_TIM16_IRQHandler
and confirmed that htim1->Instance
is null when the issue occurs. They recommended adding a null check while they continue to investigate why the interrupt is firing before the peripheral is initialized. I am surprised this was not caught by the watchpoint.
EG:
void TIM1_UP_TIM16_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 0 */
/* USER CODE END TIM1_UP_TIM16_IRQn 0 */
if (htim1.Instance != NULL)
{
HAL_TIM_IRQHandler(&htim1);
}
/* USER CODE BEGIN TIM1_UP_TIM16_IRQn 1 */
/* USER CODE END TIM1_UP_TIM16_IRQn 1 */
}
Thanks everyone for all the help! I suspect there will be some change to ST code generation in the future to resolve this, but if anyone else sees this happening I hope the above snippet helps you out!