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.

TM4C1294NCPDT: Disable UART Internal Loopback mode

Part Number: TM4C1294NCPDT


Working on an application that uses multiple UARTS for communication, and want to have a built in test that uses the Tivaware UARTLoopbackEnable, to run a simple loopback test to confirm data is being sent and processed correctly. However, I am not finding any kind of command to revert the change to internal loopback. What is the best practice for this?

Solutions I've thought of but haven't tested yet are as follows: 
Disabling all the UARTs after the built in test, and reenabling them, Hoping they come up in a default manner. 
Having the board restart after a successful built in test (Not a good solution for this). 
Not using internal loopback for the built in test. 

Any advice would be appreciated. 

  • Hi,

      For some reason there is no API to disable the loopback mode. However, reading the source code of UARTLoopbackEnable, it is a matter of setting the UART_CTL_LBE bit to enable loopback. After you finish the loopback test, you can use HWREG to clear UART_CTL_LBE manually in UART_O_CTL register. 

    //*****************************************************************************
    //
    //! Enables internal loopback mode for a UART port
    //!
    //! \param ui32Base is the base address of the UART port.
    //!
    //! This function configures a UART port in internal loopback mode to help with
    //! diagnostics and debug. In this mode, the transmit and receive terminals of
    //! the same UART port are internally connected. Hence, the data transmitted
    //! on the UnTx output is received on the UxRx input, without having to go
    //! through I/O's. UARTCharPut(), UARTCharGet() functions can be used along
    //! with this function.
    //!
    //! \return None.
    //
    //*****************************************************************************
    void UARTLoopbackEnable(uint32_t ui32Base)
    {
    //
    // Check the arguments.
    //
    ASSERT(_UARTBaseValid(ui32Base));

    //
    // Write the Loopback Enable bit to register.
    //
    HWREG(ui32Base + UART_O_CTL) |= UART_CTL_LBE;
    }

  • I'm not seeing the value of UART_CTL_LBE in my UART.H or UART.C library files. Do you know what value I would have to input in HWREG to clear it? 

  • Hi,

      They are defined in the header file C:\ti\TivaWare_C_Series-2.2.0.295\inc\hw_uart.h.