2021-01-18 06:49 PM
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();
}
2021-01-19 12:21 AM
Other values work?
Did you try with a simple "blinky" program?
> Got hard fault.
Then debug it as usually with hardfaults.
JW
2021-01-19 06:13 AM
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.
2021-01-20 12:44 AM
And using the same prescaler but different reload value?
JW
2021-02-08 12:47 PM
Hello
I have the same problem as you. Did you find the solution?
Can you help me ?
Thank you
2021-02-08 01:19 PM
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.
2021-02-10 01:17 AM
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
2021-02-10 06:19 AM
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