Skip to main content
Visitor II
April 9, 2021
Solved

STM32F767 watchdog example

  • April 9, 2021
  • 4 replies
  • 3105 views

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

    This topic has been closed for replies.
    Best answer by EGonc.2

    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

    */

    }

    4 replies

    Technical Moderator
    April 9, 2021

    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

    EGonc.2Author
    Visitor II
    April 9, 2021

    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?

    Technical Moderator
    April 16, 2021

    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

    EGonc.2AuthorAnswer
    Visitor II
    April 16, 2021

    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

    */

    }

    Technical Moderator
    April 16, 2021

    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