Specifications

344 www.xilinx.com Embedded System Tools Guide (EDK 6.2i)
1-800-255-7778 UG111 (v1.4) January 30, 2004
Chapter 23: Interrupt Management
R
unsigned int count = 1; /* default count */
unsigned int timer_count = 1; /* default timer_count */
/* uartlite interrupt service routine */
void uart_int_handler(void *baseaddr_p) {
char c;
/* till uart FIFOs are empty */
while (!XUartLite_mIsReceiveEmpty(XPAR_MYUART_BASEADDR)) {
/* read a character */
c = XUartLite_RecvByte(XPAR_MYUART_BASEADDR);
/* if the character is between "0" and "9" */
if ((c>47) && (c<58)) {
timer_count = c-48;
/* print character on hyperterminal (STDOUT) */
putnum(timer_count);
/* Set timer with new value of timer_count */
XTmrCtr_mSetLoadReg(XPAR_MYTIMER_BASEADDR, 0, (timer_count*tim
er_count+1) * 1000000);
}
}
}
/* timer interrupt service routine */
void timer_int_handler(void * baseaddr_p) {
unsigned int csr;
unsigned int gpio_data;
/* Read timer 0 CSR to see if it raised the interrupt */
csr = XTmrCtr_mGetControlStatusReg(XPAR_MYTIMER_BASEADDR, 0);
if (csr & XTC_CSR_INT_OCCURED_MASK) {
/* Increment the count */
if ((count <<= 1) > 8) {
count = 1;
}
/* Write value to gpio. 0 means light up, hence count is negated */
gpio_data = ~count;
XGpio_mSetDataReg(XPAR_MYGPIO_BASEADDR, gpio_data);
/* Clear the timer interrupt */
XTmrCtr_mSetControlStatusReg(XPAR_MYTIMER_BASEADDR, 0, csr);
}
}
void
main() {
unsigned int gpio_data;
/* Initialize exception handling */
XExc_Init();
/* Register external interrupt handler */