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.

TM4C129XNCZAD: How to enable UART1 ?

Part Number: TM4C129XNCZAD

Hello,

I'm trying to test the UART1 ports with the following code, but it is not working.

Is there anything else to be added or modifed?

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

#define UART_MODULE     UART1_BASE
#define UART_GPIO_PORT  GPIO_PORTB_BASE
#define UART_GPIO_TX    GPIO_PIN_1
#define UART_GPIO_RX    GPIO_PIN_0
#define BAUD_RATE       115200


uint32_t ui32SysClock;


void UARTInit(void)
{
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    GPIOPinConfigure(GPIO_PB0_U1RX);
    GPIOPinConfigure(GPIO_PB1_U1TX);

    GPIOPinTypeUART(UART_GPIO_PORT, UART_GPIO_RX | UART_GPIO_TX);

    UARTConfigSetExpClk(UART_MODULE, SysCtlClockGet(), BAUD_RATE,
                        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    return;
}

void LEDInit(void)
{
    // GPIO Config
    // PN0 is used for RUN LED
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);

    return;
}

void UARTPrint(const char* message)
{

    while(*message != '\0')
    {
        UARTCharPut(UART_MODULE, *message);
        message++;
        // blinking the RUN LED
    }
}

int main(void)
{

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                SYSCTL_OSC_MAIN |
                SYSCTL_USE_PLL |
                SYSCTL_CFG_VCO_480), 120000000);

    //SysCtlClockSet(SYSCTL_XTAL_25MHZ |
    //        SYSCTL_OSC_MAIN |
    //        SYSCTL_USE_PLL |
    //        SYSCTL_CFG_VCO_480);



    LEDInit();

    UARTInit();

    while(1)
    {
        UARTPrint("Hello TIVA !!! \r\n;");
        GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0);
        SysCtlDelay(1600000);
        GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 1);
        SysCtlDelay(1600000);
    }

//	return 0;
}