2021-04-09 01:29 AM
I wonder if someone can provide me with an example how to use the watchdog in a STM32F767.
I have tried the following code but it don't get a reset!
static WWDG_HandleTypeDef hwwdg;
static bool wwdg_inited = false;
static void EnableWDG (void)
{
if ( ! wwdg_inited )
{
hwwdg.Instance = WWDG;
hwwdg.Init.Prescaler = WWDG_PRESCALER_8;
hwwdg.Init.Window = 64;
hwwdg.Init.Counter = 100;
hwwdg.Init.EWIMode = WWDG_EWI_DISABLE;
if (HAL_WWDG_Init(&hwwdg) == HAL_OK)
{
if (HAL_WWDG_Refresh(&hwwdg) == HAL_OK)
wwdg_inited = true;
}
}
}
It seems that the the API has been changed. The HAL_WWDG_Start() no longer exists...
Solved! Go to Solution.
2021-04-16 01:44 AM
Now the watchdog is working!
For reasons not understood the HAL_WWDG_MspInit() function was empty instead of initializing the watchdog.
A call to __HAL_RCC_WWDG_CLK_ENABLE() was missing.
__weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
{
__HAL_RCC_WWDG_CLK_ENABLE(); <<==== MISSING
/* Prevent unused argument(s) compilation warning */
UNUSED(hwwdg);
/* NOTE: This function should not be modified, when the callback is needed,
the HAL_WWDG_MspInit could be implemented in the user file
*/
}
2021-04-09 01:36 AM
Hello @Community member ,
You can refer to the WWDG example under STM32CubeF7 in the path:
STM32Cube_FW_F7_V1.16.1\Projects\STM32F767ZI-Nucleo\Examples\WWDG\WWDG_Example
Check how this example was implemented and get inspiration to develop your application, it may helps you.
You find more details on how to use the example in the readme.txt file.
Imen
2021-04-09 02:23 AM
Thanks, but when I try to run the example on a Nucleo-144 with a STM32F767ZI it generates a timeout error when initialising the clock:
SystemClock_Config();
stm32f7xx_hal_rcc.c
HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct)
{
...
/* Wait till HSE is ready */
while (__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)
{
if ((HAL_GetTick() - tickstart) > HSE_TIMEOUT_VALUE)
{
return HAL_TIMEOUT; <<====
}
}
Is there any solution for this?
2021-04-16 01:41 AM
Hi @Community member ,
Did you added your own code and change the example ? or you are facing this issue with the provided example in Cube package ?
What about the WWDG and clock configuration ? Can you please share it ?
Imen
2021-04-16 01:44 AM
Now the watchdog is working!
For reasons not understood the HAL_WWDG_MspInit() function was empty instead of initializing the watchdog.
A call to __HAL_RCC_WWDG_CLK_ENABLE() was missing.
__weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
{
__HAL_RCC_WWDG_CLK_ENABLE(); <<==== MISSING
/* Prevent unused argument(s) compilation warning */
UNUSED(hwwdg);
/* NOTE: This function should not be modified, when the callback is needed,
the HAL_WWDG_MspInit could be implemented in the user file
*/
}
2021-04-16 02:45 AM
I'm glad that issue is resolved 🙂
I marked it as "best answer". This will help other community members finding answers to the same issue 😉
Imen
2021-04-16 04:33 AM
It is sometimes useful and productive to try reading. Like, for example, that NOTE in the comment at the end of the code you posted!