/* 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\i7188.h" unsigned long far *TimeTick=(unsigned long far *)0x0040006CL; long far *Ivect=(long far *)0L; void EnableWdt(void); void RefreshWdt(void); void main(void) { int WatchDogReset; int quit=0; unsigned long time; int fEnableWdt=1; Print("\n\rVect[255]=%8lx",Ivect[255]); Print("\n\rNow Vect[255]=%8lx",Ivect[255]); WatchDogReset=IsResetByWatchDogTimer(); if(WatchDogReset) Print("\n\r-->System was RESET by WatchDog timer"); Print("\n\rWait 5 seconds for user to press anykey to Bypass WatchDog test\n\r"); time=*TimeTick+5000; while(!quit){ Print("\r%5lu",time-*TimeTick); if(Kbhit()) { Getch(); quit=1; Print("\n\rBypass Enable watchdog."); fEnableWdt=0; } if(*TimeTick>=time){ Print("\n\rEnable watchdog."); quit=1; } } if(fEnableWdt){ Print("\n\rPress anykey to stop reset WatchDogTimer.\n\r"); EnableWDT(); time=*TimeTick; while(!Kbhit()) { RefreshWDT(); Print("\r%lu",*TimeTick-time); } Getch(); Print("\n\rWait WatchDogTimer reset I-7188..\n\r"); time=*TimeTick; while(1){ Print("\r%lu",*TimeTick-time); } } }