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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

872 Views
lpcware
NXP Employee
NXP Employee
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
Labels (1)
0 Kudos
4 Replies

468 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dariush_abbasi868 on Sun Jun 28 22:37:15 MST 2015
Hi,
I have already this problem in lpc11e68 and when I want to send bytes to UART only first byte send , I can not really understand your solution .
I 'm trying to use it in USAT2  .

could you please help me ?
0 Kudos

468 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveBan on Wed Jun 18 05:25:10 MST 2014
Thanks for the link, it helped me create a workaround.

It would be nice if NXP fixed their LPCOpen code as that code makes the same assumption that everyone else seems to be (correctly?) making which is the THR is the top element in the the TX FIFO and not the entire TX FIFO. Hence their code doesn't make use of the TX FIFO!
0 Kudos

468 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OldManVimes on Fri May 23 04:12:08 MST 2014
Have a look at this thread:  http://www.lpcware.com/content/forum/cant-get-uart-tx-fifo-to-work

Basically the UART behaves in a very counter intuitive way and writing code that makes use of the TX FIFO is not trivial.
I hope this helps.
0 Kudos

468 Views
johanborkhuis
Contributor III

Post was moved from LPCWare forum to here: https://community.nxp.com/message/873683 

0 Kudos