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.

TMS320F280039C: SCI SCIRXST.RXRDY behavior

Part Number: TMS320F280039C

Dear Champs,

I am asking this for our customer.

Because the user's application is bootloder, they don't want to use interrupt. Instead, they want to use polling-based codes to check SCI SCIRXST.RXRDY.

When they used codes like below, they found they would miss data intermittently.

pseudo code:

int main()
{
    while(1)
    {
        GetRxData();
    }
}

void GetRxData()
{
    if(SCIRXST.bit.RxRDY == 1)
    {
        Data = SCIRXBUF.bit.SAR;
    }
}

but if the user changes to codes like below, there is no missing byte.

void GetRxData()
{
    while (SCIRXST.bit.RxRDY == 0)
    {
    }
    Data = SCIRXBUF.bit.SAR;
}

However, because the use does not use interrupt, the while (SCIRXST.bit.RxRDY == 0) loop will take too much time so that the background loop is stuck in GetRxData(), which is not desired.

The user wants to use if-based codes.

Therefore, we would like to check the behaviors in more detail.

1. From "Table 25-13. SCIRXST Register Field Descriptions" of TRM,

"...RXRDY is cleared by a reading of the SCIRXBUF register, by an active SW RESET, or by a system reset...."

Case 1:

There is an input byte and the input byte is copied into SCIRXBUF and there is no further input byte. If the user does not read SCIRXBUF, RXRDY is kept HIGH unless there is a reset. Is it right?

Case 2:

There is input bytes regularly. If the next byte (say "0x02") overwrites the previous byte (say "0x01") and there is not reading to SCIRXBUF, what is the behavior of RXRDY?

Will it be kept HIGH?

Or will it HIGH (means 0x01 byte is ready to be read) and then LOW (during overwriting), and then HIGH (the 0x02 byte is ready to be read)?

Or else behavior?

That is, we want to confirm if RXRDY will drop?

  • Hi Wayne,

    Thanks for your question.

    If the user does not read SCIRXBUF, RXRDY is kept HIGH unless there is a reset. Is it right?

    Correct.

    There is input bytes regularly. If the next byte (say "0x02") overwrites the previous byte (say "0x01") and there is not reading to SCIRXBUF, what is the behavior of RXRDY?

    Will it be kept HIGH?

    Correct. RXRDY should not drop.

    Regards,

    Vince

  • Dear Vince,

    If RXRDY does not drop, do you have any comment about using if-statement in my first post?

    Why did the user miss bytes intermittently?

  • Hi Wayne,

    Can you verify if the code is "double reading" (reading the register twice) when the bit is set? I am wondering if it is clearing the bit accidentally. You can check this by adding a +1 counter within the loop and seeing if the counter is higher than the bytes received.

    Regards,

    Vince

  • Dear Vince,

    I am still confused.

    Would you please make it clearer?

  • Hi Wayne,

    What I mean is the following:

    int main()
    {
        while(1)
        {
            GetRxData();
        }
    }
    
    void GetRxData()
    {
        if(SCIRXST.bit.RxRDY == 1)
        {
            Data = SCIRXBUF.bit.SAR;
            read_counter++; // <--- THIS IS THE ADDED CODE
        }
    }

    If that counter is more than the number of bytes received, then the code is running so fast, that it's reading the buffer twice, and may be clearing RxRDY before the next byte is fully received. I don't think it's likely, but we need to test it to make sure whether or not it is happening for the customer.

    Regards,

    Vince

  • Dear Vince,

    As the waveform shows, there is no glitch on the debug pin (CH.3) which means that double reading does not happen in this moment.

     

    Is there any other reason to cause this missing RxRDY issue?

     

    Besides, could you please help advise how much time it spends from reading the RxBuffer to RxRDY going low?

    Is the current main loop timing proper in this case?

     

    Here is the pseudo code the user tested.

    int main()
    {
            while(1)
            {
                Toggle CH4;
                GetRxData();
            }
    }
    void GetRxData()
    {
            if(SCIRXST.bit.RxRDY == 1)
            {
                Data = SCIRXBUF.bit.SAR;
                Toggle CH3; // The pin should go high and low in a short period while it is double read.
            }
    }
    

  • Hi Wayne,

    I am looking into this, and will let you know what I find. I believe this might be as simple as the loop maybe not actually calling the function, which could be a compiler optimization issue (unlikely).

    Regards,

    Vince

  • Hi Wayne,

    So one thing that I remmebered while testing this was that errors can cause this to not flag at the appropriate time. Can you show the RXST register value when a read doesn't occur when expected? Basically, I think likely scenario is that some error is set and preventing a byte from registering the RXRDY bit.

    Regards,

    Vince

  • Dear Vince,

    Because this is urgent, let's discuss this offline.

    After we find the solution, we can be back to update and share with others.

    Wayne

  • Dear Vince,

    The user found another root cause in their codes and solved this issue.

    Thank you for your support.