// Some further examples of setting timer unit
// No. 3 - Polling of Real time Clock
// I.T. - 25/10/04
#include <stdio.h>
/*Real time clock program - POLLING of timer*/
void main()
{
unsigned char *padr,*paddr,*tflg2,*pactl,*tmsk2;
int hours,mins,secs,ticks;
tflg2=(unsigned char*)0x25;
pactl=(unsigned char*)0x26;
*pactl = 0x3;
for(;;)
{
*tflg2 = 0x40; /*reset timer*/
while((*tflg2 & 0x40) == 0); /*wait for timeout*/
ticks++;
if (ticks>=30)
{
ticks=0;
secs++;
printf("%i:%i:%i\r",hours,mins,secs);
}
if (secs>=60)
{
secs=0;
mins++;
}
if (mins>=60)
{
mins=0;
hours++;
}
if (hours>=24)
{
hours=0;
}
}
}