cancel
Showing results for 
Search instead for 
Did you mean: 

IWDG of STM32F103 work in hardware watchdog mode, question

lzyos
Associate II

IWDG of STM32F103 work in hardware watchdog mode, by set MCU's option bytes.

My question is "Once the option byte wrote, software need not start the IWDG by code, even after many times reset ( include software reset , PVD reset, IWDG reset) IWDG is still functional.

here is my code for setting the option byte of IWDG to hardware watchdog mode.

***************************

usrOption = FLASH_GetUserOptionByte();

if( (usrOption&OB_IWDG_SW) != 0)

{

FLASH_Unlock();

FLASH_EraseOptionBytes();

FLASH_UserOptionByteConfig(OB_IWDG_HW,OB_STOP_NoRST,OB_STDBY_NoRST);

FLASH_Lock();

OSTimeDlyHMSM(0, 0, 1, 0);

OS_ENTER_CRITICAL();  

NVIC_SystemReset();

OS_EXIT_CRITICAL();

}

**************************

9 REPLIES 9
lzyos
Associate II

After EMC shocks, my PCB frozen , looks like IWDG is not functional.

In the task of feed IWDG, I turn on and turn off a LED indicator, so I can sure nobody feed the IWDG

**********************************

IWDG->KR = ((uint16_t)0xAAAA);

iWdgCnt++;

if( iWdgCnt == 5)

{

GPIO_ResetBits(LED_PORT, LED_PIN1);

}

else (iWdgCnt == 10)

{

GPIO_SetBits(LED_PORT, LED_PIN1);

iWdgCnt = 0;

}

*************************************

thank you for the advice​

Does an External reset button recover it, or do you have to cycle the power to recover from the latch-up?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
lzyos
Associate II

So sorry, there is no reset button on my design. Currently I have to cycle the power to recover

It would have been a way to double check. The IWDG can only pulse the reset, and if that doesn't break the condition you are dead in the water.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
lzyos
Associate II

ok...... Clive

Do you the code for "set the option byte of IWDG hardware watchdog mode" is right?

lzyos
Associate II

Is there any other condition IWDG not functional, except SWD debug? Like standby mode / sleep or something else, for stm32f103 chips?

> In the task of feed IWDG, I turn on and turn off a LED indicator, so I can sure nobody feed the IWDG

I wouldn't rely on human eye in this. Runaway software may behave in unexpected ways, e.g. timing you are accustomed to may not work correctly. Use oscilloscope or logic analyzer to observe this pin.

JW

lzyos
Associate II

JW,

> Runaway software may behave in unexpected ways

Nice advice, I will do some trouble shooting by  oscilloscope or logic analyzer

lzyos
Associate II

JW, one more question.

Enalbe LSI, and reconfig IWDG should not STOP running IWDG, right?

On ST's comments, IWDG started, software can not stop it by any way.

**********************************************

RCC_LSICmd(ENABLE);

while( RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET )

{

LSI_CNT++;

if( LSI_CNT > 100) break;

}

..................

..................

IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);

  

  //40K/256 = 156HZ(6.4ms)  

IWDG_SetPrescaler(IWDG_Prescaler_256);

//150 * 6.4 about 960ms

IWDG_SetReload(150);

  IWDG_Enable();

IWDG_ReloadCounter();  

**************************************