I'm just getting started with using the Keil uV3 compiler as well as the Phillips lpc2129. The application I am working on requires both UART0 & 1 as well as the I2C and I'm wondering if anyone has some <sample> code for enabling/using interrupts handy for this part that they might could pass along to help me get started. Any links related to writing C code for the lpc2129 would also be appreciated. regards & thanks -mel
Thanks for the code, for the most part what I came up with was (about) the same. I am not using printf and therefor have not added syscalls.c to my project. Also adding that file will require some work on my part as I have three different put/get-char calls (et al. putchar_uart0, putchar_uart1, putchar_i2c) but no get/put char as required in syscalls.c. My code is not performing correctly regarding the interrupts for uart1. I'll post the code here and also in a new thread for possible extra help. First of all, here is the main loop...
while(1) { cTemp = getchar_uart1(); if( cTemp ) putchar_uart1( cTemp ); cTemp = 0; }
void u1_interrupt (void) __attribute__ ((interrupt)); /* generate interrupt */ /*************************************************************************/ /************************** interrupt for uart1 ************************/ void u1_interrupt (void) { char intrpt; intrpt = U1IIR; /* reset U1IIR register */ // for now just trying to echo the Rx'd byte back out uart1... intrpt = U1RBR; // clear Rx buffer, and reset interrupt putchar_uart1( intrpt ); VICVectAddr = 0; /* acknowledge interrupt */ }/*end u1_interrupt() */ 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 RBR and RLS 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()
I thought it worth mentioning that I can see the Rx Data Ready interrupt triggering when I am single stepping in the debug mode but flow does NOT jump it my ISR. also FYI: with regards to posting code... use the
</per> tags to retain formatting
"</per> tags to retain formatting" That should be < pre > (to start) and < /pre > (to end) - but without the extra spaces. It's clearly shown at the top of the form when you make a post!
excuse my typos... I got the first one correct which was why it wasn't displayed which is also why you put the spaces between the brackets (I hadn't thought of that either)