lpcware

LPCOpen UART Code for LPC17xx doesn't use the TX FIFO

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Nov 22, 2017 by Johan Borkhuis
Content originally posted in LPCWare by DaveBan on Sat May 17 09:44:54 MST 2014
Hello,

In the uart_17xx_40xx.c source file in the lpc_chip_175x_6x project found in LPCOpen 2.10, the following function should (I believe) use the TX FIFO to send a string. However, with both TX and RX FIFOs enabled on an LPCXpresso LPC1769 board, the function only ever sends one character. To send 8 characters for example requires calling this function 8 times.

/* Transmit a byte array through the UART peripheral (non-blocking) */
int Chip_UART_Send(LPC_USART_T *pUART, const void *data, int numBytes)
{
int sent = 0;
uint8_t *p8 = (uint8_t *) data;

/* Send until the transmit FIFO is full or out of bytes */
while ((sent < numBytes) &&
   ((Chip_UART_ReadLineStatus(pUART) & UART_LSR_THRE) != 0)) {
Chip_UART_SendByte(pUART, *p8);
p8++;
sent++;
}

return sent;
}


I was expecting it to send as many characters as slots were available in the TX FIFO, but this doesn't seem to be the case and only a single character is sent each time the function is called. I've tried this with different baud rates but see the same behavior. At start-up, I'm calling the LPCOpen Chip_UART_Init function which enables the FIFOs and can step through the code to ensure the relevant code sections are being executed.

It looks like the TX FIFO is not working as advertised but unfortunately the user manual does not contain many much detail on the UART FIFO.

One point to mention is I can step through the code above when debugging via semihosting and see the code work as expected when sending say an 8 byte character string (i.e. the code in the while loop executes 8 times). I'm sure this is because the UART is transmitting the data far faster than I can manually step through the code so the THR is always empty. This suggests the TX FIFO is a single character deep and not the 16 bytes as expected.

Can anyone help with this issue?

Thanks.
David

Outcomes