/* 1. Compiler: TC 2.0 2. Mode: Large 3. Project: watchdog.prj watchdog.c ..\lib\8000l.lib ..\lib\tcpipl.lib 4. Explain: (1) Demo program for 8831 to test if 8831 is reset by watchdog timer. (2) 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." (3) Then you can press any key to bypass Watchdog timer test,or wait 5 seconds to test watchdog timer. 5. Hordware: 8831 It's compiled by Tony ---------------------------------------------------------------------------------------- */ #include #include #include #include #include #include"..\LIB\8000.h" #include"..\LIB\vxcomm.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 PowerReset; int quit=0; unsigned long time; int fEnableWdt=1; int type; int ver; type=Is8000(); /*detect the current operation system*/ if(type) { ver=GetLibVersion(); /*if used in minios7*/ Print("Hello 8831! (Flash memory is %d K)\n\r",type); Print("Library version is %d.%02d",ver>>8,ver&0xff); } else /*if used in dos*/ { Print("Hello PC!, this program is not run under 8831."); return; } Print("\n\rVect[255]=%8lx",Ivect[255]); PowerReset=IsResetByPowerOff(); Print("\n\rNow Vect[255]=%8lx",Ivect[255]); if(PowerReset) Print("\n\r-->System was power off then power on"); 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); } } }