ENDAT
‐
N3410
User’s
Manual
UNICORN
COMPUTER
CORP.
Copyright 2015 Unicorn Computer Corporation. All rights reserved.
45
4.
Appendix
4.1.
WDT
and
Digital
I/O
programming
1A
‐
Watch
Dog
Timer
Watch dog Timer (WDT) is a special design for system monitoring to secure the system work normally. WDT has an
independent clock from the oscillator and could set time and clear/refresh WDT counter function. When time is up, WDT will
send hardware RESET signal to reset system.
Timeout
Value
Range
1. Set value, 1 to 255
2. Set timer for count “Second” or “Minute”.
Sample
code
(using TurboC/C++ 3.0):
//--------------------------------------------------------------------------------Start Programming---------------------------------------------------------------------
#include <stdio.h>
#include <dos.h>
#include <dir.h>
void show_ver();
void main()
{
unsigned int tt;
clrscr();
show_ver();
tt=0;
while((tt==0)||(tt>255))
{
printf("\n\nPlease key in how many seconds you want to reset system (1~255):");
scanf("%d",&tt);
}
outportb(0x2e,0x87); //Unlock register
outportb(0x2e,0x87); //Unlock register
outportb(0x2e,0x07); //set Logic Device number pointer
outportb(0x2f,0x08); //set Logic Device number
outportb(0x2e,0x30); //set WDTO active
outportb(0x2f,0x01); //set reg value active (bit0 =1 active,0 inactive )
outportb(0x2e,0xf2); //set WDTO Control Mode
outportb(0x2f,0x00); //set register value Default :00h
//bit7 Mouse interrupt reset enables watch-dog timer reload
// 0: Watchdog Timer I is not affected by mouse interrupt.
// 1: Watchdog Timer I is reset by mouse interrupt.
// bit6 Keyboard interrupt reset enables watch-dog timer reload
// 0: Watchdog Timer I is not affected by keyboard interrupt.
// 1: Watchdog Timer I is reset by keyboard interrupt.
outportb(0x2e,0xf0); //set WDTO Control Mode
outportb(0x2f,0x00); //set register value Default :00h
// (bit3=1: minute. =0: second)
outportb(0x2e,0xf1); //set WDT Counter
outportb(0x2f,tt);
//set time out value of WDT
}
void show_ver()