|
楼主 |
发表于 2015-4-1 16:58:23
|
显示全部楼层
以下是主函数的代码,代码基本是官方的看门狗例程,仅是屏蔽了看门狗的喂狗指令。上电后,蓝色的LED开始闪烁,可见程序并未复位。
int main (void)
{
WDOG_ConfigType sWDOGConfig = {0}; /*! < watchdog configuration structure */
/* Perform processor initialization */
sysinit();
sWDOGConfig.sBits.bWaitEnable = TRUE;
sWDOGConfig.sBits.bStopEnable = TRUE;
sWDOGConfig.sBits.bDbgEnable = TRUE;
sWDOGConfig.sBits.bUpdateEnable = FALSE;
sWDOGConfig.sBits.bDisable = FALSE; /* enable WDOG */
sWDOGConfig.sBits.bClkSrc = WDOG_CLK_INTERNAL_1KHZ;
sWDOGConfig.u16TimeOut = 1000; /*< 1s */
sWDOGConfig.u16WinTime = 0;
WDOG_Init(&sWDOGConfig);
printf("\nRunning the wdog_feed_demo project.\n");
if(WDOG_IsReset()) /*!< check if wathdog reset happens */
{
/*! watchdog happens. */
LED0_Init(); /*!< initialize red light */
while(1)
{
LED0_Toggle(); /*!< flash red light if watchdog reset occurs */
WDOG_Feed();
DelayUS(50000); /*!< delay around 50ms */
}
}
/*! watchdog does not happens, then flash blue led. */
LED2_Init(); /*!< initialize blue light */
while(1)
{
LED2_Toggle(); /*!< flash blue light if no watchdog reset occurs */
//WDOG_Feed();
DelayUS(50000); /*!< delay around 50ms */
}
} |
|