2018-12-27 04:02 PM
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();
}
**************************
2018-12-27 04:11 PM
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
2018-12-27 04:16 PM
Does an External reset button recover it, or do you have to cycle the power to recover from the latch-up?
2018-12-27 05:17 PM
So sorry, there is no reset button on my design. Currently I have to cycle the power to recover
2018-12-27 06:46 PM
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.
2018-12-27 07:22 PM
ok...... Clive
Do you the code for "set the option byte of IWDG hardware watchdog mode" is right?
2018-12-27 07:42 PM
Is there any other condition IWDG not functional, except SWD debug? Like standby mode / sleep or something else, for stm32f103 chips?
2018-12-28 01:56 AM
> 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
2018-12-28 04:11 AM
JW,
> Runaway software may behave in unexpected ways
Nice advice, I will do some trouble shooting by oscilloscope or logic analyzer
2018-12-28 04:23 AM
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();
**************************************