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.

TM4C123GH6PM: Unable to send data over UART1

Part Number: TM4C123GH6PM


Hi all,

I am trying to send data over UART1 on PD0 and PD1 but the Tx pin is not transmitting. Am I missing something. I have adapted the code from UART_loopback example code

//*****************************************************************************
//
// uart_echo.c - Example for reading data from and writing data to the UART in
//               an interrupt driven fashion.
//
// Copyright (c) 2011-2017 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 2.1.4.178 of the DK-TM4C123G Firmware Package.
//
//*****************************************************************************
// LED anode is tied to 3.3V and cathode to 1k resistor and finally to PB1


#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/rom.h"
#include "grlib/grlib.h"
#include "drivers/cfal96x64x16.h"

#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif

int main(void)
{
    ROM_FPULazyStackingEnable();
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // Set the clocking to run directly from the crystal.
    //Init UART0
    SysCtlDelay(10);
    //Init UART1
    
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // Enable the peripherals used by UART 1
    SysCtlDelay(10000);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    SysCtlDelay(10000);
    ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); // Set GPIO B0 and B1 as UART pins
    SysCtlDelay(10000);
    ROM_UARTConfigSetExpClk(UART1_BASE,
                            ROM_SysCtlClockGet(),
                            9600,
                            (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE)); // Configure the UART0 for 9600, 8-N-1 operation
    SysCtlDelay(10000);



    while(1)
    {
        ROM_UARTCharPut(UART1_BASE,'1');
        SysCtlDelay(1000000);
    }

}

  • Found the issue. For some reason the individual pins PB0 and PB1 have to be explicitly configured for working as TX and RX. Had to add three lines of code

    #include "driverlib/pin_map.h"

    GPIOPinConfigure(GPIO_PB0_U1RX);
    GPIOPinConfigure(GPIO_PB1_U1TX);