From 21dd5edf3294644946c2b06e64eb84ed365197a9 Mon Sep 17 00:00:00 2001 From: Elliott Partridge Date: Thu, 6 Jun 2024 09:52:20 -0400 Subject: [PATCH] fix: Eliminated HardFault after reset under debug Reported in https://github.com/STMicroelectronics/x-cube-azrtos-h7/issues/38 PCC/MXCubeGenerated/Core/Src/stm32h7xx_hal_timebase_tim.c - Moved interrupt enable after timer initialization. After reset, timer interrupt was firing before the handle was initialized, resulting in a HardFault. --- .../Core/Src/stm32h7xx_hal_timebase_tim.c | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/PCC/MXCubeGenerated/Core/Src/stm32h7xx_hal_timebase_tim.c b/PCC/MXCubeGenerated/Core/Src/stm32h7xx_hal_timebase_tim.c index 831e7d7..bd1cf1b 100644 --- a/PCC/MXCubeGenerated/Core/Src/stm32h7xx_hal_timebase_tim.c +++ b/PCC/MXCubeGenerated/Core/Src/stm32h7xx_hal_timebase_tim.c @@ -46,19 +46,6 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) uint32_t uwPrescalerValue; uint32_t pFLatency; -/*Configure the TIM6 IRQ priority */ - if (TickPriority < (1UL << __NVIC_PRIO_BITS)) - { - HAL_NVIC_SetPriority(TIM6_DAC_IRQn, TickPriority ,0U); - - /* Enable the TIM6 global Interrupt */ - HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); - uwTickPrio = TickPriority; - } - else - { - return HAL_ERROR; - } /* Enable TIM6 clock */ __HAL_RCC_TIM6_CLK_ENABLE(); @@ -98,8 +85,18 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) if(HAL_TIM_Base_Init(&htim6) == HAL_OK) { - /* Start the TIM time Base generation in interrupt mode */ - return HAL_TIM_Base_Start_IT(&htim6); + /*Configure the TIM6 IRQ priority */ + if (TickPriority < (1UL << __NVIC_PRIO_BITS)) + { + HAL_NVIC_SetPriority(TIM6_DAC_IRQn, TickPriority ,0U); + + /* Enable the TIM6 global Interrupt */ + HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); + uwTickPrio = TickPriority; + + /* Start the TIM time Base generation in interrupt mode */ + return HAL_TIM_Base_Start_IT(&htim6); + } } HAL_TIM_RegisterCallback(&htim6, HAL_TIM_PERIOD_ELAPSED_CB_ID, TimeBase_TIM_PeriodElapsedCallback); -- 2.45.1.windows.1