cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 - IWDG

pierre-yves
Associate III
 
1 ACCEPTED SOLUTION

Accepted Solutions
pierre-yves
Associate III

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 .

View solution in original post

7 REPLIES 7
pierre-yves
Associate III

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.

Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
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

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
pierre-yves
Associate III

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
Associate III

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 .