I'm working on developing interrupt driven comms for an lpc2129 and having a problem getting the interrupts working. It all seemed fairly straight forward so I must be missing something. What I have is a short main loop that will echo back any Rx'd bytes on uart1. This works fine until I enable the interrupts for uart1 at which point something goes amuk. The ISR for uart1 is going to echo the rx'd byte back out the port - simple enough to get started with. When I enable uart1 interrupts and single step via the debugger, I can see the Receive Data Ready interrupt bit get set when I send the uart a character. However, flow continues normally - that is, no jump is made to the ISR. The character I send is then echoed back via the code in the main loop (NOT the ISR). When I run the code without the debugger I get nothing back from the board via uart1 so I'm assuming I'm getting hung up someplace. This is the main loop:
while(1) { if( getchar_uart1() ) putchar_uart1( cTemp ); /* echo any bytes Rx'd */ }
int getchar_uart1( void ) { if( U1LSR & 0x01 ) /* if data return it */ return (U1RBR); else return 0; }/* end getchar_uart1 */
void init_uart1( void ) { PINSEL0 |= 0x00550000; /* set P0.8, P0.9, P0.10 and P0.11 as TxD1, RxD1, RTS1, CTS1 */ U1LCR = 0x83; /* set DLAB and word size (8bits), defaults for others yield */ /* no parity, one stop bit, and no break */ U1DLL = 0x61; /* yields 9600 Baud */ U1DLM = 0x00; /* explicit initialization - is also the default */ U1LCR &= 0x7f; /* clear DLAB */ /* set up the interrupts */ U1IER = 0x05; /* enable RDA and THRE interrupts */ VICVectAddr1 = (unsigned long) u1_interrupt; /* set interrupt vector */ VICVectCntl1 = 0x20 | 7; /* use VICVectAddr1 for UART1 interrupts */ VICIntEnable = 0x00000080; /* enable uart1 interrupts */ }/* end init_uart1() */
void u1_interrupt (void) __attribute__ ((interrupt)); /* generate interrupt */ /*************************************************************************/ /************************** interrupt for uart1 ************************/ void u1_interrupt (void) { if( U1IIR && U1LSR &= 0x20 ) /* Tx buffer empty? - also clearing U1IIR */ U1THR = U1RBR; /* echo the Rx'd byte */ VICVectAddr = 0; /* acknowledge interrupt */ }/*end u1_interrupt() */