Skip to main content
This topic has been closed for replies.
Best answer by pierre-yves

Hello

I found, certainly related to updating the HAL layers and the configuration of the watchdog IWDG.

it works with:

hiwdg.Init.Prescaler = IWDG_PRESCALER_32;
hiwdg.Init.Window = IWDG_WINDOW;
hiwdg.Init.Reload = 1000;

it does not work with:

hiwdg.Init.Prescaler = IWDG_PRESCALER_4;
hiwdg.Init.Window = IWDG_WINDOW;
hiwdg.Init.Reload = 259;

For infomormation

#define IWDG_WINDOW IWDG_WINDOW_DISABLE

I wished to have a watchdog at 500ms. i

In the good configuration , it is 1s .

7 replies

pierre-yves
Associate III
February 8, 2021

205 / 5000

Hello

I want to use the IWDG component.

I activated the module with HAL_IWDG_MODULE_ENABLED and configure the clocks (LSI):

	RCC_OscInitStruct.OscillatorType 	= RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
	RCC_OscInitStruct.HSEState 			= RCC_HSE_ON;
	RCC_OscInitStruct.LSIState 			= RCC_LSI_ON;
	RCC_OscInitStruct.PLL.PLLState 		= RCC_PLL_ON;
	RCC_OscInitStruct.PLL.PLLSource 	= RCC_PLLSOURCE_HSE;
	RCC_OscInitStruct.PLL.PLLM 			= RCC_PLLM_DIV4;
	RCC_OscInitStruct.PLL.PLLN 			= 70;
	RCC_OscInitStruct.PLL.PLLP 			= RCC_PLLP_DIV10;
	RCC_OscInitStruct.PLL.PLLR 			= RCC_PLLR_DIV5;
	if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
	{
		Error_Handler();
	}

Here is my source code to initialize the watchdog:

IWDG_HandleTypeDef hiwdg;
 
hiwdg.Instance 			= IWDG;
hiwdg.Init.Prescaler 	= IWDG_PRESCALER_32;
hiwdg.Init.Window 		= IWDG_WINDOW;
hiwdg.Init.Reload 		= IWDG_RELOAD;
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
{
	Error_Handler();
}

with :

#define IWDG_WINDOW IWDG_WINDOW_DISABLE
#define IWDG_RELOAD 1500

When the HAL_IWDG_Init function is executed, the microcontroller arrives in HardFault_Handler

The following operation goes wrong: IWDG_ENABLE_WRITE_ACCESS (hiwdg);

Do you have any ideas ?

Thank you in advance.

ST Technical Moderator
February 9, 2021

Hello @pierre-yves​ ,

Which STM32CubeG0 MCU package are you using?

Please make sure to use the latest release of CubeG0 package as contains a fix in HAL_IWDG_DEFAULT_TIMEOUT define related to IWDG start-up timeout insufficiently low issue.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
pierre-yves
Associate III
February 10, 2021

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
February 10, 2021

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

ST Technical Moderator
February 10, 2021

Hi @pierre-yves​ ,

I advise you use the latest release of STM32CubeG0 MCU package (version 1.4.0) as contains a fix in IWDG driver.

Then, please keep me updated on your progress on this issue.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
pierre-yves
Associate III
February 12, 2021

Hello

Thank you for your comeback.

I updated the HAL layers to version 1.4.0.

I have the same problem.

it is this operation that goes wrong: IWDG_ENABLE_WRITE_ACCESS (hiwdg); i.e. hiwdg-> Instance-> KR = IWDG_KEY_WRITE_ACCESS_ENABLE,

Can you help me ?

pierre-yves
pierre-yvesAuthorBest answer
Associate III
February 12, 2021

Hello

I found, certainly related to updating the HAL layers and the configuration of the watchdog IWDG.

it works with:

hiwdg.Init.Prescaler = IWDG_PRESCALER_32;
hiwdg.Init.Window = IWDG_WINDOW;
hiwdg.Init.Reload = 1000;

it does not work with:

hiwdg.Init.Prescaler = IWDG_PRESCALER_4;
hiwdg.Init.Window = IWDG_WINDOW;
hiwdg.Init.Reload = 259;

For infomormation

#define IWDG_WINDOW IWDG_WINDOW_DISABLE

I wished to have a watchdog at 500ms. i

In the good configuration , it is 1s .