Specifications
Appendix B: Programming the Watchdog Timer
Page A5
BB
#define T2CH2CNT 0x82 /* timer 2 counter address */
#define TIMER2CW 0xb6 /* counter 2, write, mode 3, bin
*/
#define TIMERTICKRESOLUTION 15 /* Timer has 15 microsecond tick
*/
#define TIMERINT 8 /* PC timer interrupt vector */
#define TIMER2TICKS 0xffff /* ~491 milliseconds
*/
#define SMOUTCTRL 0xfe /* reset enable latch */
void (INTERRUPT *previoustimerfunction)();
volatile unsigned long Tick = 0;
#pragma intrinsic(_disable,_enable,inp,inpw,outp,outpw)
unsigned char
getconfigurationregister(unsigned short slregister)
{
outp(CFGINDEX,slregister);
return ((unsigned char) inp(CFGDATA));
}
void
setconfigurationregister(unsigned short slregister,unsigned char
slvalue)
{
outp(CFGINDEX,slregister);
outp(CFGDATA,slvalue);
}
unsigned short
saveflags()
{
unsigned short flags;
ASM
pushf
pop flags
ENDASM
return flags;
}
void
restoreflags(unsigned short flags)
{
ASM
push flags
popf
ENDASM
}
unsigned short
enablespace()
{
unsigned short flags;
/*
// Any interrupt that occurs between saveflags & disable
// should restore the flag register (via the iret).
// Therefore, the flags variable is guaranteed to contain a
// copy of the machines state prior to disabling
// interrupts.
*/
flags = saveflags();
_disable();
/*