AM263P4: RX error determination of "UART_getCharFifo" function

Part Number: AM263P4

Tool/software:

Hi, TI experts.

The UART example "uart_echo_low_latency_polling" use the function of "UART_getCharFifo".

The function is defined in "/source/drivers/uart/v0/lld/uart_v0.lld.c".

It seems that the function discard received RX data with ALL RX error.

(The function "UART_readByte" we cannot access is the same.)

I think some modification is needed.

Regard,

Jeeuk Chang

  • Hi Jeeuk,

    Let me review the code and get back

    Regards,
    Shaunak

  • Hi Jeeuk Chang,

    I tested the uart_echo_low_latency polling example and after sending 8 bytes from the UART Console, i did reach the UART_getCharFifo() function, in which I observe no error count. The errorVal is 0 and when we perform the check for "Read and throw Erroneous bytes from RxFIFO", since the errorVal is 0, we skip the while loop and directly read the byte from RxFIFO (as expected).

    Do you mind trying this binary just to make sure we don't have any unexpected modifications on your end.

    AM263Px-CC binary:

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/908/uart_5F00_echo_5F00_low_5F00_latency_5F00_polling.debug.out

    AM263Px-LP Binary:

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/908/uart_5F00_echo_5F00_low_5F00_latency_5F00_polling.debug.out

    Regards,
    Shaunak

  • Hi Shaunak Deshpande,

    -

    I am sorry not to explain my question in detail.

    I had no error in performing the UART examples because normally RX errors do not occur.

    I am pointing out the LLD function with RX error handling.

    -

    The function "UART_fifoCharGet" read 1 byte from RX fifo simply.

    -

    And the funcion "UART_readByte" read 1 byte after discarding RX data with RX errors.

    I thought the function should discard RX data with ANY RX error but actually the function discard RX data only with ALL RX errors.

    (In order to perform the statements in "while", All RX errors must be issued.)

    -

    The function "UART_getCharFifo" read 1 byte from RX fifo with changing LCR temporarily and checking RX errors.

    This function also discard RX data only with ALL RX errors.

    -

    Regard,

    Jeeuk Chang

  • Hi Jeeuk,

    Thanks for the explanation,

    Looking at the UART_readByte and UART_getCharFifo functions, you're partially correct in your analysis, but there's an important detail about the error checking.

    In UART_readByte (lines 1058-1086), the code checks for errors with this condition:
    while ((UART_LSR_RX_FIFO_STS_MASK |
    UART_LSR_RX_BI_MASK |
    UART_LSR_RX_FE_MASK |
    UART_LSR_RX_PE_MASK |
    UART_LSR_RX_OE_MASK) == errorVal)

    This is checking if errorVal equals ALL error flags combined. You're right that this would only discard bytes if all possible RX errors occur simultaneously (break error, framing error, parity error, and overrun error), which is unlikely.

    However, looking at UART_procLineStatusErr (lines 2617-2694), there's additional error handling. This function is called when line status errors are detected, and it specifically checks for individual error types:

    if ((lineStatus & UART_BREAK_DETECTED_ERROR) != 0U)
    {
    hUart->readTrans.status = UART_TRANSFER_STATUS_ERROR_BI;
    hUart->readErrorCnt++;
    }
    else if ((lineStatus & UART_FRAMING_ERROR) != 0U)
    {
    hUart->readTrans.status = UART_TRANSFER_STATUS_ERROR_FE;
    hUart->readErrorCnt++;
    }
    else if ((lineStatus & UART_PARITY_ERROR) != 0U)
    {
    hUart->readTrans.status = UART_TRANSFER_STATUS_ERROR_PE;
    hUart->readErrorCnt++;
    }
    else
    {
    hUart->readTrans.status = UART_TRANSFER_STATUS_ERROR_OE;
    hUart->readErrorCnt++;
    }

    This function is called by the interrupt handler (UART_lld_controllerIsr) when line status errors are detected.

    So while the specific byte reading functions you mentioned may only discard bytes with all error types simultaneously (which appears to be a bug), the driver does handle individual errors properly at the interrupt level through UART_procLineStatusErr.

    To properly handle individual errors in UART_readByte and UART_getCharFifo, the condition should check for ANY error (with a bitwise OR operation) rather than requiring ALL errors to match.

    Let me raise a bug internally and get the implementation reviewed by our driver experts.

    Regards,
    Shaunak

  • I have raised a bug internally for review: https://jira.itg.ti.com/browse/MCUSDK-14895

    Regards,
    Shaunak

  • Hi Shaunak Deshpande,

    Because I use the custom protocol with UART, I use only several functions of UART LLD function.

    TI drivers are good starting point to make my own custom driver.

    I wish TI drivers have fewer bugs for other people.

    Regards,

    Jeeuk Chang

  • Hi Jeeuk,

    Apologies that you had to face this bug, I have initiated a discussion with the team to get the resolution for this bug. This will be fixed in the next SDK release on ti.com and the fix will also be available soon via GitHub TI SDK (before the ti.com official release)

    Regards,
    Shaunak