/* WDOGTST.C * * This example program shows how the watchdog timer may be used. * This program enables the watchdog timer and then continues * to strobe the timer so that it does not time out. * When the key is hit, the program ceases to strobe the * watchdog and will reset the system after the timeout period. */ #include #include void interrupt far newtimer( void ); int WdogStrobed; #define WDTMR 0xFE4C /* write only */ /* the following define allows this program to be compile under Microsoft or Borland C */ #ifdef __TURBOC__ #ifndef outp #define outp outportb #endif #ifndef _dos_setvect #define _dos_setvect setvect #endif #endif void PrintMenu(void) { if (WdogStrobed) printf("Watchdog strobed. Hit to disable strobing\n"); else printf("Watchdog not strobed\n"); } void EnableWdog(void) { _dos_setvect(0x1C, newtimer); } main() { int key; WdogStrobed = 1; printf("**********************************************************\n"); printf("****************** Watchdog timer test *******************\n"); printf("**********************************************************\n"); PrintMenu(); EnableWdog(); for(;;) { if (kbhit()) { key =getch(); if ((key == 'S')||(key == 's')) WdogStrobed = 0; PrintMenu(); } if (WdogStrobed) outp(WDTMR,0); /* strobes watchdog */ } } /* this interrupt service routine does nothing but return */ void interrupt far newtimer() { }