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.

CCS/EK-TM4C129EXL: UART Sending Packet

Expert 1660 points
Part Number: EK-TM4C129EXL


Tool/software: Code Composer Studio

hi i am trying to send the packet array {0x01,0x02,0x03,0x04,0x05} using uart 7 of tiva 

but i received in ccs terminal incorrect values 

here is my code 

#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "inc/hw_memmap.h"
#include "inc/hw_uart.h"
#include "inc/hw_types.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"




//*****************************************************************************
//
// Macros used in this application.
//
//*****************************************************************************
#define NUM_UART_DATA    5
    uint8_t ui8DataTx[NUM_UART_DATA]={0x01,0x02,0x03,0x04,0x05};
    uint32_t ui32index;

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif

//*****************************************************************************
//
// Send a string to the UART.  This function sends a string of characters to a
// particular UART module.
//
//*****************************************************************************
void
UARTSend(  uint8_t *pui8Buffer, uint32_t ui32Count)
{
    //
    // Loop while there are more characters to send.
    //
    while(ui32Count--)
    {


      while(!(ROM_UARTSpaceAvail(UART7_BASE))); // return true if there is space , return false if there is no space

      ROM_UARTCharPutNonBlocking(UART7_BASE, *pui8Buffer++);  // wait until character is transmitted

    }

}

//*****************************************************************************
//
// Configue UART in internal loopback mode and tranmsit and receive data
// internally.
//
//*****************************************************************************
int
main(void)
{

    uint32_t ui32SysClock;

    //
    // Set the clocking to run directly from the crystal.

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |
                                       SYSCTL_USE_OSC), 25000000);


    //
    // Enable the peripherals used by this example.

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);



        GPIOPinConfigure(GPIO_PC4_U7RX);
        GPIOPinConfigure(GPIO_PC5_U7TX);
        ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);


    //
    // Configure the UART for 115,200, 8-N-1 operation.

   ROM_UARTConfigSetExpClk(UART7_BASE, ui32SysClock, 115200,
                            (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                             UART_CONFIG_PAR_NONE));


    //
 //  ROM_UARTFIFOEnable(UART7_BASE);

    UARTSend( ui8DataTx, NUM_UART_DATA);


   while(1);
}

  • Hi,

      You are using the EK-TM4C129EXL launchPad, correct? Only UART0 and UART2 are connected to the virtual COM port of the ICDI. If you are using the UART7 without an external USB to serial adapter such as FT2232H from FTDI then it will not work. If you have an USB to serial adapter connected and is seeing garage then please check if you have matching parameters like the baud rate, stop bits, parity bit between the two nodes. Do you see the same problem with other UART modules? If you are seeing the same problem with other UART modules then it is likely your port settings are not matching. I will suggest you also try the TivaWare uart_echo example. It is using UART0 in the example. But if you are seeing the garbage on your terminal window then it kind of confirm the incorrect port setting The example uses 115200 baud rate with 8 bit data and 1 stop bit with no parity. 

     

      

       

  • Ahmad,

    Appears CCS terminal is displaying hexadecimal as higher ASCII code set symbols. Following Charles great advice to use (virtual com) you can then use Realterm (github.com) or perhaps older Putty to display hexadecimal numbers on the host computer. 

    https://github.com/vaibhavp369/Software-