cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F767 watchdog example

EGonc.2
Associate II

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...

1 ACCEPTED SOLUTION

Accepted Solutions
EGonc.2
Associate II

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

*/

}

View solution in original post

6 REPLIES 6
Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
EGonc.2
Associate II

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?

Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
EGonc.2
Associate II

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

*/

}

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

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!