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.

RTOS/AM5728: UART Rx ring buffer

Part Number: AM5728

Tool/software: TI-RTOS

I'm configuring a situation very similar to the one described in this thread: https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/694614.

I've got everything working accept for if the packet size is larger than the default ring buffer(which I've seen mentioned in multiple help threads). According to the other thread:

"There is a internal ring buffer to store the received data that arrives in between calls to UART_read so you should not lose any bytes in the "Non ideal case". The size of the ring buffer is configurable inside the device board file."


I'm really struggling to find where exactly the ring buffer is defined in the board files. Is there an example somewhere that someone would be able to direct me towards?

Thank you!

  • The RTOS team have been notifies. They will respond here.
  • John,

    the UART driver implementation for connected MCU Simplelink SDK and Processor SDK RTOS is different. though the APIs are compatible, but Processor SDK RTOS UART driver doesn`t use a internal ring implementation. It uses the UART built in FIFO and associated interrupts to trigger transfers to move data in and out of IO buffers.

    UART read in call back mode uses the following API call flow between APP, UART LLD And CSL librayr:

    If you provide more details on your usecase, we may be able to provide guidance.

    Regards,

    Rahul

  • Thank you very much Rahul for this information, it helped me understand and figure out a little more of what was happening with my code. It appears that my second UART_read was obtaining the full packet, but my UART_write was not printing it all properly. I originally had 3 UART_writes in a row, with the third printing out what was received from UART_read but it was truncating the data. If I stepped through the writes it works correctly, or if I remove the first two writes then the third one prints correctly. I'll only need one write for my release version, but I was curious as to why having several in a row would cause issues?

    I also had an issue that my very first read would not grab all the data correctly unless I manually cleared the RX FIFO register. But with the configuration below, everything appears to be working the way I was expecting. Here's a snippet of my uart_task and the rx callback function:

    Void uart_test(UArg arg0, UArg arg1)
    {
        char echoNewline[] = "\n\r";
        char echoPrompt[] = "\nuart driver example test:\n\r";
        char echoPrompt1[] = "\nData received is\n\r";
    
        while(1)
        {
            HW_WR_FIELD32(UART_BASE_ADDRESS + UART_FCR, UART_FCR_RX_FIFO_CLEAR, 1); // Clear Rx FIFO register
    
            UART_read(uart5_handle, rxUartBuf, 1);           // read first byte of packet: bytesToFollow
            Semaphore_pend(hSem, BIOS_WAIT_FOREVER);
    
            UART_read(uart5_handle, rxUartBuf, MAX_TX_PACKET_SIZE);  // read remaining bytes in packet
            Clock_start(clockUartReadTimeout);                  // start one-shot timer for UART_readCancel()
            Semaphore_pend(hSem, BIOS_WAIT_FOREVER);
    
            if(txPktSzError) {
                memset(txUartBuf, 0, MAX_RX_PACKET_SIZE);   // clear txBuf array
                memset(rxUartBuf, 0, MAX_TX_PACKET_SIZE);   // clear rxBuf array
                continue;
            }
            
            //UART_write(uart5_handle, echoNewline, sizeof(echoNewline));   // commented out so printing of txUartBuf works properly
            //UART_write(uart5_handle, echoPrompt1, sizeof(echoPrompt1));   // commented out so printing of txUartBuf works properly
    
            UART_write(uart5_handle, txUartBuf, txBytes);    // Display data received
    
            memset(txUartBuf, 0, MAX_RX_PACKET_SIZE);   // clear txBuf array
            memset(rxUartBuf, 0, MAX_TX_PACKET_SIZE);   // clear rxBuf array
    
            UART_write(uart5_handle, echoPrompt, sizeof(echoPrompt)); // Display prompt again
        }
    }
    
    static void uartRxCb(UART_Handle handle, void *buf, size_t count) {
        txPktSzError = 0;
        if(count == 1)
        {
            txBytes = rxUartBuf[0];
        }
        else
        {
            if(txBytes == count)
            {
                //Copy rxBuf to txBuf
                memset(txUartBuf, 0, MAX_RX_PACKET_SIZE);
                memcpy(txUartBuf, rxUartBuf, txBytes);
            }
            else
            {
                txPktSzError = 1;
            }
        }
    
        //Wake task to echo
        Semaphore_post(hSem);
    }
    
    Void uartReadTimeout(UArg arg)
    {
        UART_readCancel(uart5_handle);
    }

    Thank you again!