Zilog EZ80F916 User Manual
Page 160
UM014423-0607
Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!
®
User Manual
140
init_timer1();
// Init 100ms Timer - enable timer 1 ISR
_ei();
// Turn on the master interrupt system.
do
{
Your code goes here....
}while(1);
/****************************************************************
* This will initialize timer1 to interrupt every 10 ms
*
* 16 bit time constant is not big enough for 100 ms interrupts,
* so we will use additional intermediate counter to count
* every 10 ticks.
*/
void init_timer1(void)
{
ticks1 = 0x00;
intermediate_ticks1 = 0x00;
TMR_CTL1 = 0x00;
TMR_RRL1 = 0xFF;
//setup timer to interrupt every 10ms
TMR_RRH1 = 0x1F;
TMR_CTL1 = 0x0e;
//timer0 = multipass, /16, interrupt enable
TMR_CTL1 |= 0x01; //enable timer
TMR_IER1 = 0x01; // Enables timer 1 interrupt
}
void init_com1(void)
{
PC_ALT1 &= 0xf0;
//PD0 = uart0_tx, PD1 = uart0_rx
PC_ALT2 |= 0x0F;
UART_LCTL1=0x80;
//select dlab to access baud rate generators
BRG_DLRL1=0x45;
// 9600
BRG_DLRH1=0x01;
UART_LCTL1=0x00;
//disable dlab
UART_FCTL1=0xc7;
//clear tx fifo, clear rx fifo, fifo enable
UART_LCTL1=0x1B;
//8-N-1
UART_MCTL1=0x20;
//disable modem flow control
UART_IER1=0x05;
//rx int enable, master int enable was 1
}
#pragma interrupt