beautypg.com

ADLINK MXC-6300 Series User Manual

Page 108

background image

96

Watchdog Timer (WDT) Function Library

/* set timeout value as 10 seconds */

/* WDT start automatically while timeout value is set

*/

w_reg(0x73,0x0A);

printf("----------------------------------------------

-----\n");

printf("WDT is set and counting down

now.<<<<<<<<<<<<<<<<<<\n");

printf("----------------------------------------------

-----\n");

for(count=10;count!=0;count--)

{

printf("Countdown %2d : 0xF6=%2x Press any key to

invoke keyboard interrupt.\n",count,r_reg(0xF6));

/* reset WDT timeout value to 10 seconds */

/* w_reg(0x73,0x0A); */

sleep(1);

}

printf("At least one keyboard interrupt must occur

during countdown.\n");

printf("Otherwise WDT has already reset system.\n\n");

printf("Try again and leave keyboard.\n\n");

/* disable WDT */

/* WDT stop while timeout value is set to zero */

w_reg(0x73,0x00);

printf("WDT is disable. Program is terminating.");

ExitConfig();

return 0;

}