2020-02-19 20:58发布
鲜衣怒马 发表于 2015-4-1 16:54 路过帮顶,楼主最好把代码贴出来,大神们才能帮忙
postek 发表于 2015-4-1 17:55 如果不断重启的话,能从灯上判断出来不?
最多设置5个标签!
以下是主函数的代码,代码基本是官方的看门狗例程,仅是屏蔽了看门狗的喂狗指令。上电后,蓝 {MOD}的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(" Running the wdog_feed_demo project. ");
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 */
}
}
可以,如果重启,红 {MOD}的灯会闪烁(重启之前蓝 {MOD}的灯闪烁)。
一周热门 更多>