LPC UART question

Hi.

I’m writing an application for LPC2138 that is interrupt driven on UARTO. My program interrupts when an Rx event takes place. My ISR just does:

cChar = U0RBR;

I need to be able to Tx asynchonously and I use this to send a character (eventually I’ll send a chain of characters):

while (U0LSR & 0x20 != 0x20);
 U0THR = ch0; //where ch0 is the byte the send

Can I do this, or do I need to prevent the UART receiving to be able to send? Or can I do both at the ‘same time’.

Thanks.

Can I do this, or do I need to prevent the UART receiving to be able to send? Or can I do both at the ‘same time’.

I’m 99% sure you’re safe, as UARTS are designed to be bi-directional and independently RX/TX (as long as you’re not using control lines like RTS CTS).

Several uart interrrupts can occur simultaneously. You need an ISR that reads the interrupt register and then handles all the cases based on the bits that are set. Besides Rx and Tx interrupts there are framing errors and maybe overflow errors.

To use interrupts successfully you will probably need an Rx queue, and a Tx queue. Your ISR will put into the RX queue, and the application will pull from it. The opposite for the Tx queue. Of course the application has to disable interrupts while it is operating on the queues.

Without queues, the application has to handle characters at the reception rate and is pretty much a slave to the RX interrupts. With a queue the application only has to keep up with the average character rate, which is usually substantially less than the maximum possible rate. The Rx queue has to be long enough to handle the maximum burst length expected

In my code there is the ISR and the two queues. Above that is a system task that interfaces to the queues and provides application funtionality like getchar(), gets(), putchar() and puts().