CP/386LN WATCHDOG TIMER
The CP/386LN offers non-stop operation for critical embedded PC applications such as medical
instruments, security systems, test equipment, and communication devices with
an watchdog timer. A watchdog timer is used to restart the CP/386LN in case normal
operation is interrupted by unexpected events such as software or hardware failures
and power brownouts. The CP/386LN watchdog timer is supported by the EMBEDDED
SYSTEM BIOS ESB386EX with 3 functions:
| BIOS Int. 15h, AX= 0C301h START WATCHDOG TIMER |
| BIOS Int. 15h, AX= 0C302h TRIGGER WATCHDOG TIMER |
| BIOS Int. 15h, AX= 0C300h STOP WATCHDOG TIMER |
If an application program starts the watchdog timer, the watchdog timer must
periodically be retriggered by the application program. When a timeout condition
occurs, the CP/386LN watchdog timer restarts the system by generating a hardware
reset. The timeout value can be set with BIOS Interrupt 15h / AX= 0C301h (START WATCHDOG
TIMER). The function needs the timeout value in 80x86 register BX. The integer value
382 is an timeout from 1 sec., 382 * 2 is 2 sec., 382 * 3 is 3 sec. watchdog timeout and
so on. The following C sourcecode shows an example for an watchdog timeout from 5 sec.
This code was written in Borland Turbo C for DOS.
/****************************************************************************/
/* Programm: WATCHDOG.C */
/* Version.: 1.00 */
/* Date....: 14.04.1996 KDW */
/* LUPD....: 14.04.1996 KDW */
/* */
/* Watchdog Timer demo program for 386EX CPU with SSV EMBEDDED SYSTEM BIOS */
/* (ESB386EX). This BIOS supports the INTEL 386EX internal WATCHDOG with */
/* BIOS interrupt 15h. This program shows the 3 main functions: 1.) START */
/* WATCHDOG; 2.) (RE)TRIGGER WATCHDOG and 3.) STOP WATCHDOG. */
/****************************************************************************/
/************/
/* Includes */
/************/
#include stdio.h
#include dos.h
#include bios.h
/***********************/
/* FunctionPrototyping */
/***********************/
unsigned char main (void); /* main................ */
void StartWatchdog (void); /* START WATCHDOG...... */
void TriggerWatchdog (void); /* (RE)TRIGGER WATCHDOG */
void StopWatchdog (void); /* STOP WATCHDOG....... */
/****************************************************************************/
/* Function: main -- Trigger Watchdog if the user press a key ... */
/****************************************************************************/
unsigned char main (void)
{
/************/
/* Variable */
/************/
int LoopFlag, c;
/**************************************************************/
/* Start Watchdog and enter loop. Wait for key's in this loop */
/**************************************************************/
clrscr ();
LoopFlag= 1;
StartWatchdog (); /* Start Watchdog.... */
printf ("**** START WATCHDOG TIMER. ****\n");
printf ("-------------------------------\n");
while (LoopFlag) {
/************************************************************/
/* ... Wait for Key, Display ScanCode & KeyCode and trigger */
/* Watchdog. Stop Watchdog and exit program if ESC. */
/************************************************************/
c= bioskey (0);
TriggerWatchdog ();
cprintf ("TRIGGER WD. Key SC/KC 0x%02X/0x%02X\n\r", (c >> 8) & 0xff, c & 0xff);
/*******************************/
/* ... Checks for ESC key here */
/*******************************/
if ((c & 0xff) == 0x1b) LoopFlag= 0;
}
StopWatchdog (); /* Stop Watchdog.... */
printf ("-------------------------------\n");
printf ("***** STOP WATCHDOG TIMER *****\n");
return (1); /* Exit Program here */
}
/****************************************************************************/
/* Function: StartWatchdog -- Start Watchdog Timer with 5 sec. Timeout */
/****************************************************************************/
void StartWatchdog (void) {
union REGS inregs, outregs; /* 80x86 Registers */
/********************************************************/
/* ... uses ESB386EX Int. 15h / AX= 0C301h, BX= timeout */
/********************************************************/
inregs.x.ax= 0xc301;
inregs.x.bx= 382*5; /* TimeOut = 5 Sec. */
int86 (0x15, &inregs, &outregs);
}
/****************************************************************************/
/* Function: TriggerWatchdog -- (Re)Trigger Watchdog */
/****************************************************************************/
void TriggerWatchdog (void) {
union REGS inregs, outregs; /* 80x86 Registers */
/*******************************************/
/* ... uses ESB386EX Int. 15h / AX= 0C302h */
/*******************************************/
inregs.x.ax= 0xc302;
int86 (0x15, &inregs, &outregs);
}
/****************************************************************************/
/* Function: StopWatchdog -- Stop Watchdog */
/****************************************************************************/
void StopWatchdog (void) {
union REGS inregs, outregs; /* 80x86 Registers */
/*******************************************/
/* ... uses ESB386EX Int. 15h / AX= 0C300h */
/*******************************************/
inregs.x.ax= 0xc300;
int86 (0x15, &inregs, &outregs);
}
/****************************************************************************/
SSV SOFTWARE SYSTEMS PC/104 Products. CP/386LN-WD. File:
P65.HTM, Last Update: 20-January-1997
Copyright (c) 1996, 1997 WST. All rights reserved.