This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

6678 UART losing rx characters during send

I am using the UART on the 6678 as a debug interface to a PC, and have found that when it is sending a continuous stream of data, it ignores or loses incoming characters.

My send and receive functions are based on the EVM sample code, but adapted for a multi-thread environment.  The UART is set up in FIFO mode, with interrupts disabled.  The send routine polls the THRE bit until it indicates that the tx fifo is empty, with a short thread sleep between checks (instead of the busy loop from the sample code), then writes one character and waits again.

If the UART sends multiple strings in a row (dumping an event log), and does a single check of the DR bit between each string, it almost never catches an incoming character - even holding down a repeat key, it almost never catches any.  If I put a pause between each string, and check the DR bit continuously for 1ms, then it usually catches it, but that slows down the throughput to an unacceptable degree.  If I only put that pause every few lines, then it still misses incoming characters.

I have now added a check of the DR bit inside the send routine, so it checks DR between each outgoing character, and between each check of THRE, and sets a flag if DR was set.  Now it always catches DR high for even a single incoming character, but when I get to the end of the outgoing string and try to read it, DR is already clear and the incoming character is lost.

  • Hey Paul,

    Okay, so your main issue is that when you receive the information from the UART, your RX data/character is either lost or  dropped. I'm assuming this is without a pattern. The UART is actually a kind of "dumb" IP, which you probably already know, since it just dumps it out. You have it setup in the FIFO CPU poll mode (since interrupts are disabled).

      I had a similar issue with this using MSP430 and UART to output it a while back. Most of the time I've had problems is that I *think* I'm sampling a one baud rate, but my EVM is actually sending it out at another, and so we'd miss stuff. I'd have to enable oversample (which is some thing you could try) for it to match the speed and see it. So, check that.

     What does RXFIFOE say? Is it counting the errors or flushing it out? How are you reading/rx the data? If I were you, I would have the UART connect to the PC and use Tera Term (a free downloadable program that just reads serial input) to see what's happening. And then I'd go step by step in my code (pausing every line) and see if there is a pattern to what data it seems to drop. If I could figure out a way to see what data is going in,and match what data is going out, I would do that.

    However, If you  are really in a pickle, try adding a software buffer ontop of the FIFO rx buffer. So that way it just dumps it there before it fills up. That way you can determine if it's a buffer issue, or a setup issue.

     

    Try that, and see what happens.

    Kat Kelsch  

     

     

  • I found the problem!  In the EVM sample code, when it writes to the Transmit Holding Register, it uses the following macro:

    CSL_FINS(hUartRegs->THR, UART_THR_DATA, uchByte);

    This macro reads the register, then replaces the specified bits with the supplied data, then writes the register back.  Unfortunately, THR and RBR share one register, depending on whether you read or write, so every time it writes the register using that macro, it accidentally reads a byte from the receive FIFO.

    I have changed that to:

    hUartRegs->THR = uchByte;

    Now the receive FIFO is unaffected by sending bytes.

  • Great! Glad it was solved.