cancel
Showing results for 
Search instead for 
Did you mean: 

Odd Issue With STM32L071CB When Initialising Watchdog

MClarke
Visitor

I'm having an issue with initialising my watchdog, when I include the call to HAL_WWDG_INIT(&hwwdg2) in my code, it is causing any debug attempt to run into the hardfault handler due to some values in SystemClock_Config() being set to 0:

 

__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
{
/* Configure the SysTick to have interrupt in 1ms time basis*/
if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)
{
return HAL_ERROR;
}

...

 

The SystemCoreClock and uwTickFreq values both get set to 0 when the execution reaches them. If I comment out my HAL_WWDG_INIT call, the execution will work without issue. The HAL_WWDG_INIT isn't even being ran before whatever is happening happens, if I put a breakpoint on both there and in the HAL_InitTick function, the HAL_InitTick function is reached first with the values altered.

 

Here's my Watchdog initialisation, it seems fairly innocuous:

static void MX_WWDG_Init(void)
{
hwwdg2.Instance = WWDG;
hwwdg2.Init.Prescaler = WWDG_PRESCALER_1;
hwwdg2.Init.Window = 64;
hwwdg2.Init.Counter = 64;
hwwdg2.Init.EWIMode = WWDG_EWI_DISABLE;
 
if (HAL_WWDG_Init(&hwwdg2) != HAL_OK)
{
Error_Handler();
}
 
/* USER CODE BEGIN WWDG_Init 0 */
 
/* USER CODE END WWDG_Init 0 */
 
/* USER CODE BEGIN WWDG_Init 1 */
 
/* USER CODE END WWDG_Init 1 */
 
/* USER CODE BEGIN WWDG_Init 2 */
 
/* USER CODE END WWDG_Init 2 */
 
}
 
If anyone has any insight or advice, I would be grateful to receive any!
0 REPLIES 0