beautypg.com

Acrosser AR-B8170 User Manual

Page 30

background image

AR-B8170 User Manual

#include
#include

//===========================================================================
// Normal procedure
//===========================================================================
void Show_Help();

//===========================================================================
// Main procedure
//===========================================================================
int main(int argc, char *argv[])
{
unsigned char IO_Port_Address=0x22;

// Index Port 22h, Date Port 23h

unsigned char Signal;
unsigned char Time;
unsigned long Timer;
unsigned char Counter0;
unsigned char Counter1;
unsigned char Counter2;

int Temp;

if ( argc != 3 )
{ Show_Help(); return 1; }

clrscr();

Signal=atoi(argv[1]);

// Signal Set Bits

Signal=Signal<<4;

Time=atoi(argv[2]);

// Watchdog counter

Timer=Time*32768;
Counter0=(unsigned char)Timer;
Counter1=(unsigned char)(Timer>>8);
Counter2=(unsigned char)(Timer>>16);

// Select Watchdog Signal Source
outportb(IO_Port_Address,0x38); // WDT0 signal select
outportb(IO_Port_Address+1,Signal);

// Set Watchdog timer
outportb(IO_Port_Address,0x39); // WDT0 Counter0
outportb(IO_Port_Address+1,Counter0);

outportb(IO_Port_Address,0x3A); // WDT0 Counter1
outportb(IO_Port_Address+1,Counter1);

outportb(IO_Port_Address,0x3B); // WDT0 Counter2
outportb(IO_Port_Address+1,Counter2);

// Set Watchdog Enabled.
outportb(IO_Port_Address,0x37); // WDT0 Enabled Control Reg.
outportb(IO_Port_Address+1,0x40);


textcolor(YELLOW);
for(Temp=Time;Temp>0;Temp--)
{
gotoxy(20,10);

if(Signal==0xD0)
cprintf(">>> After %3d Second will reset the system. <<<",Temp);
else
cprintf(">>> After %3d Second Watchdog Signal will occur. <<<",Temp);

30