/* WATCHDOG.C demo program for I-7188 to test if I-7188 is reset by watchdog timer. If system is reset by watchdog timer,then load this file and run it, the program will show the message "System was Reset by watchdog timer." Then you can press any key to bypass Watchdog timer test,or wait 5 seconds to test watchdog timer. */ #include #include #include"..\lib\7188.h" main() { int WatchDogReset; int PowerReset; int quit=0; unsigned long time; InitLib(); PowerReset=IsResetByPowerOff(); WatchDogReset=IsResetByWatchDogTimer(); printf("\n1st time call IsResetByWatchDogTimer()"); if(PowerReset) printf("\n(1)System was power off then power on"); if(WatchDogReset){ printf("\n(1)System was Reset by watchdog timer."); } else { printf("\n(1)System was Not Reset by watchdog timer."); } printf("\n2nd time call IsResetByWatchDogTimer()"); if(IsResetByWatchDogTimer()){ /* this condition will never occure */ printf("\n(2)System was Reset by watchdog timer."); } else { /* call IsResetByWatchDogTimer() again always return not reset by WDT */ printf("\n(2)System was Not Reset by watchdog timer."); } TimerOpen(); printf("\nWait 5 seconds for user to press anykey to Bypass WatchDog test"); StopWatchStart(0); while(!quit){ if(kbhit4()) { getch4(); quit=1; printf("\nBypass Enable watchdog."); } StopWatchReadValue(0,&time); if(time>=5000){ printf("\nEnable watchdog."); EnableWDT(); quit=1; } } printf("\ndelay 2 secs for watchdog to reset system(if watchdog is enabled).\n"); DelayMs(2000); TimerClose(); }