cancel
Showing results for 
Search instead for 
Did you mean: 

Could not set IWDG timeout to max (~32s) for STM32G031?

Ccui.1
Associate II

I am using Nucleo-G031K board and attempt to set IWDG timeout to max value of ~32s. Got hard fault. Here is the code. Any idea?

 iwdg_hIwdg.Instance = IWDG;

 iwdg_hIwdg.Init.Prescaler = IWDG_PRESCALER_256;

 iwdg_hIwdg.Init.Window = IWDG_WINDOW_DISABLE;

 iwdg_hIwdg.Init.Reload = 4095; 

 if (HAL_IWDG_Init(&iwdg_hIwdg) != HAL_OK)

 {

  iwdg_ErrorHandler();

 }  

7 REPLIES 7

Other values work?

Did you try with a simple "blinky" program?

> Got hard fault.

Then debug it as usually with hardfaults.

JW

Ccui.1
Associate II

Other values work. For example, the following code works as expected.

 iwdg_hIwdg.Instance = IWDG;

 iwdg_hIwdg.Init.Prescaler = IWDG_PRESCALER_128;

 iwdg_hIwdg.Init.Window = IWDG_WINDOW_DISABLE;

 iwdg_hIwdg.Init.Reload = 4095; 

 if (HAL_IWDG_Init(&iwdg_hIwdg) != HAL_OK)

 {

  iwdg_ErrorHandler();

 }  

I will checkout sample application.

And using the same prescaler but different reload value?

JW

PDAMN.1
Associate

Hello

I have the same problem as you. Did you find the solution?

Can you help me ?

Thank you

Ccui.1
Associate II

HAL_IWDG_DEFAULT_TIMEOUT could be as high as 48ms. I configured system tick for 0.5ms. After I more than doubled the value as shown below

/* Status register need 5 RC LSI divided by prescaler clock to be updated. With

  higher prescaler (256), and according to LSI variation, we need to wait at

  least 6 cycles so 48 ms. */

#define HAL_IWDG_DEFAULT_TIMEOUT      110 // 48u

it works.

pierre-yves
Associate III

Hello

To test, I modified the define:

#define HAL_IWDG_DEFAULT_TIMEOUT 2000

it is indeed the macro IWDG_ENABLE_WRITE_ACCESS (hiwdg) which generates an error (HardFault_Handler).

I also changed the values

hiwdg.Instance = IWDG;

hiwdg.Init.Prescaler = IWDG_PRESCALER_128;

hiwdg.Init.Window = IWDG_WINDOW;

hiwdg.Init.Reload = 4095;

Not easy .... any ideas? .. I block

Thnak you

pierre-yves
Associate III

In fact it is indeed a timeout error made by the HAL_IWDG_Init function. But I don't know what to do.

I am in version 1.3.0 at the HAL software