Page 445 - Programming Microcontrollers in C
P. 445
430 Chapter 8 MCORE, A RISC Machine
minutes=0;
if(++hours>MAX_HOURS)
hours=MIN_HOURS;
}
}
output_time();
}
}
void output_time(void)
{
putchar(‘\r’);
putchar(hi(hours));
putchar(lo(hours));
putchar(‘:’);
putchar(hi(minutes));
putchar(lo(minutes));
putchar(‘:’);
putchar(hi(seconds));
putchar(lo(seconds));
}
/* initialize the PIT */
void pit_init(void)
{
ITCSR.OVW=ON; /* set-up ITDR to ITADR overload */
ITDR=TWO_MS; /* interrupt each two milliseconds */
ITCSR.RLD=ON; /* enable reload mode */
ITCSR.ITIF=ON; /* clear the interrupt flag */
ITCSR.ITIE=ON; /* enable the pit interrupt */
FIER.EF8=ON; /* enable the AVEC interrupt */
ITCSR.EN=ON; /* enable the pit */
}
/* in this isr, all that must be done is to turn off the pit
interrupt request bit and increment the global parameter
count */
void pit_isr(void)
{
ITCSR.ITIF=ON; /* ON clears the interrupt bit in these
registers */
count++;
}
main()

