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.

TMS320F28379D: SCI_writeCharBlockingFIFO() in sci.h still has bug as of C2000ware version 3.04

Part Number: TMS320F28379D

The code from sci.h is shown:

static inline void
SCI_writeCharBlockingFIFO(uint32_t base, uint16_t data)
{
    //
    // Check the arguments.
    //
    ASSERT(SCI_isBaseValid(base));

    //
    // Wait until space is available in the transmit FIFO.
    //
    while(SCI_getTxFIFOStatus(base) == SCI_FIFO_TX15)
    {
    }

    //
    // Send a char.
    //
    HWREGH(base + SCI_O_TXBUF) = data;
}

However the waiting condition should be:

while(SCI_getTxFIFOStatus(base) == SCI_FIFO_TX16)

This can cause an excessive amount of time spent in the interrupt in the following case:

void init()
{
...

    SCI_enableInterrupt(BaseAddress, (SCI_INT_RXFF | SCI_INT_TXFF));

    SCI_setFIFOInterruptLevel(BaseAddress, SCI_FIFO_TX1, SCI_FIFO_RX1);
    
...
}

void tx_isr()
{
    do
    {
        //let SCI TX Fifo push out to SXITXBUF
        if (txCBuff.isEmpty())
        {
            SCI_disableInterrupt(BaseAddress,SCI_INT_TXFF);
            break;
        }

        SCI_writeCharBlockingFIFO(BaseAddress,txCBuff.pop());


    } while(SCI_getTxFIFOStatus(BaseAddress) < SCI_FIFO_TX16);

...    
}

In the above example, the device interrupt will hang waiting for the TX FIFO to drop below 15 whenever the 16th byte is attempted to be added. 

The TI response in the previous thread (see related, 10 months ago), stated it would be fixed in the next release. It was not.

  • Hi Owen,

    The idea behind keeping the wait condition is to make sure that we write to the TXBUF only when there's an empty block in the FIFO.

    In the case that you mentioned, while(SCI_getTxFIFOStatus(base) == SCI_FIFO_TX16), the indication is that the FIFO is already full and we proceed to write to the TXBUF.

    Give me a day to verify this update before I make changes to the driver. I'll let you know whatever solution we come up with. Sorry for the delay.

    Thanks,

    Aditya

  • In the code, the  while(SCI_getTxFIFOStatus(base) == SCI_FIFO_TX16) {} will hang when the buffer is full, not proceed as you have stated.

    With the current code (using SCI_FIFO_TX15), the driverlib will allows writes to proceed if the buffer is actually full (i.e. adding a byte when the status is SCI_FIFO_TX16 does not cause a waiting condition). It can also mess up timing if external logic is also checking for a full FIFO state (as shown in my example). 

  • Owen,

    Thanks for the clarification. I'll update it and should be available very soon in the next release. Sorry for the delay though!

    Regards,

    Aditya