beautypg.com

Watchdog timer, Ar-b5890 user manual – Acrosser AR-B5890 User Manual

Page 19

background image

AR-B5890 User Manual

19

WATCHDOG TIMER

//===========================================================================

// Turbo C++ Version 3.0 Copyright(c) 1990, 1992 by Borland International,Inc.

//===========================================================================

// Describe : ITE8718F WatchDog timer test

// Date : 12/16/2009

// Author : Willy

//===========================================================================

#include

#include

#include

#include

//===========================================================================

// Main procedure

//===========================================================================

int main(int argc, char *argv[])

{

unsigned char IO_Port_Address=0x2E;

unsigned char Time;

unsigned int Temp;

long int Time1 = 0, C = 0;

if ( argc != 2 )

{ Show_Help(); return 1; }

clrscr();

Time=atoi(argv[1]);

// Set Watchdog

outportb(IO_Port_Address,0x87);

// Enter configure

outportb(IO_Port_Address,0x01);

outportb(IO_Port_Address,0x55);

outportb(IO_Port_Address,0x55);

outportb(IO_Port_Address,0x07);

// Point to Logical Device Number Reg.

outportb(IO_Port_Address+1,0x07); // Select logical device 7, (Watchdog Function)

outportb(IO_Port_Address,0x23);

// Select Watchdog use CLKIN

outportb(IO_Port_Address+1,inportb(IO_Port_Address+1)|0x10);

outportb(IO_Port_Address,0x72);

// Select Watchdog use keyboard reset

outportb(IO_Port_Address+1,0x40);

outportb(IO_Port_Address,0x72);

// Select Watchdog count mode seconds or minutes

outportb(IO_Port_Address+1,inportb(IO_Port_Address+1)|0x80); // Set Second

if (Time != 0)

{

Time1 = Time;

C = ( Time1 * (0x64) ) / (0x6C); // Time = Time * 1.08 (offset)