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.

TM4C1230H6PM: UART communication issue : Data incorrect

Part Number: TM4C1230H6PM
Other Parts Discussed in Thread: EK-TM4C123GXL

Hi,

I am using the TM4C1230H6PM custom board. I am transmitting data on REAL TERM (using PC) to a Custom board (using FTDI USB TO TTL). The transmitted data from Real Term and received data on Controller do not match. I am getting the following data.

      Tx (REAL TERM)      Rx(Custom Board)

1.    0x02                         0x0C

2.    0x05                         0x13

3.    0x07                         0x1F

      Tx (Custom Board)      Rx(REAL TERM)

1.    0x0C                             E2

2.     0x13                            E5

3.    0x1F                             E7

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"

//*****************************************************************************
//
//! \addtogroup uart_examples_list
//! <h1>UART Polled I/O (uart_polled)</h1>
//!
//! This example shows how to set up the UART and use polled I/O methods
//! for transmitting and receiving UART data.  The example receives characters
//! from UART0 and retransmits the same character using UART0.  It can be
//! tested by using a serial terminal program on a host computer.  This
//! example will echo every character that is type until the return/enter key
//! is pressed.
//!
//! This example uses the following peripherals and I/O signals.  You must
//! review these and change as needed for your own board:
//! - UART1 peripheral
//! - GPIO Port C peripheral (for UART1 pins)
//! - UART1RX - PC4
//! - UART1TX - PC5
//
//*****************************************************************************

//*****************************************************************************
//
// Configure the UART and perform reads and writes using polled I/O.
//
//*****************************************************************************
int
main(void)
{
    char cThisChar;
    // Enable the peripherals used by this example.
    // The UART itself needs to be enabled, as well as the GPIO port
    // containing the pins that will be used.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

    //
    // Configure the GPIO pin muxing for the UART function.
    // This is only necessary if your part supports GPIO pin function muxing.
    // Study the data sheet to see which functions are allocated per pin.
    // TODO: change this to select the port/pin you are using
    //
    GPIOPinConfigure(GPIO_PC4_U1RX);
    GPIOPinConfigure(GPIO_PC5_U1TX);

    //
    // Since GPIO C4 and C5 are used for the UART function, they must be
    // configured for use as a peripheral function (instead of GPIO).
    // TODO: change this to match the port/pin you are using
    //
    GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);

    //
    // Configure the UART for 115,200, 8-N-1 operation.
    // This function uses SysCtlClockGet() or ui32SysClock to get the system clock
    // frequency.  This could be also be a variable or hard coded value
    // instead of a function call.
    //
    //
    // Put a character to show start of example.  This will display on the
    // terminal.
    //
    UARTCharPut(UART1_BASE, 'S');

    //
    // Enter a loop to read characters from the UART, and write them back
    // (echo).  When a line end is received, the loop terminates.
    //
    do
    {
        //
        // Read a character using the blocking read function.  This function
        // will not return until a character is available.
        //
        cThisChar = UARTCharGet(UART1_BASE);

        //
        // Write the same character using the blocking write function.  This
        // function will not return until there was space in the FIFO and
        // the character is written.
        //
        UARTCharPut(UART1_BASE, cThisChar);
    }
    while((cThisChar != '\n') && (cThisChar != '\r'));

    //
    // Put a character to show the end of the example.  This will display on
    // the terminal.
    //
    UARTCharPut(UART1_BASE, 'S');

    //
    // Return no errors
    //
    return(0);
}

When I run the same code on TM4C123 Lunachpad and use FDTI USB to TTL adapter, I do not get this inconsistency. 

I have attached the schematic for reference. This has worked on our other boards earlier. Right now to test the issues, I have removed the MAX481ESA and connected the Uart pins directly to ensure that the chip is not causing the issue. 

  • Just a guess - it looks a bit like transmission speed incompatibility. Is your custom board running at the same clock rate? Can you compare the Tx waveform of the 2 boards with a scope?

  • Hi,

      Nowhere in your code do I see you configure the UART baudrate, length, stop bits and etc. Please see below example to configure for baudrate of 115200, 8bit char length, one stop bit and no parity. You must have both PC side and MCU side configured with identical parameters. 

    UARTConfigSetExpClk(UART0_BASE, MAP_SysCtlClockGet(), 115200,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE));

    Please also refer to example C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\uart_echo.