EasyManua.ls Logo

C&T Solution CT-MCL01 Series - Watchdog Timer

Default Icon
72 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CT-MCL01 l User’s Manual
71
Watchdog Timer
Board Design
The Watchdog Timer (WDT) is implemented by Nuvoton NCT6106D.
Psuedo Code
#include<dos.h>
#include<stdio.h>
void main(void){
// for 2E
int x,pre_rd,rd,status;
clrscr();
outportb(0x2E,0x87);
outportb(0x2E,0x87);
outportb(0x2E,0x30); //CR30 bit1=1 pin77 select WDTO#
outportb(0x2F,0x01);
outportb(0x2E,0x07);
outportb(0x2F,0x08); //Logic Device8 (LD8)
outportb(0x2E,0x30);
outportb(0x2F,0x01); //Enable WDTO#
// Reset WDTO# and clear WDTO# timeout event
outportb(0x2E,0xF6);
outportb(0x2F,0x00); //Reset WDTO# Timer
outportb(0x2E,0xF7); //Logic Device 8, CRF7
outportb(0x2F,0x00); //Write Bit4=0 to clear WDTO# event!
// Input Timer value
printf("Enter WDTO# Timer(second):");
scanf("%d",&x);
pre_rd = x + 1;
// Set Timer and Start count
outportb(0x2E,0xF6); //LD8,CRF6h Set WDTO# Timer
outportb(0x2F,x);
// Check the timeout event
// LDN8 CRF7[4] = 1 (Timeout occur)
do{
// Read Count
outportb(0x2E,0xF6); //LD8,CRF6h Set WDTO# Timer
rd = inportb(0x2F);
// Read Timeout event
outportb(0x2E,0xF7); //Logic Device 8, CRF7
status = inportb(0x2F);
// check pre-status
if (rd < pre_rd){
printf("Timer = %d\n",rd);
pre_rd = rd;
}
}while(status != 0x10);
printf("Timer Timeout.\n");
printf("Input any key to reset timeout event\n");
getch();
// Reset WDTO# and clear WDTO# timeout event
outportb(0x2E,0xF6);
outportb(0x2F,0x00); //Reset WDTO# Timer
outportb(0x2E,0xF7); //Logic Device 8, CRF7
outportb(0x2F,0x00); //Write Bit4=0 to clear WDTO# event!
Appendix WDT & GPIO

Table of Contents