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 Launchpad UART2 config

Other Parts Discussed in Thread: TM4C123GH6PM

Hello people from TI.

I am trying to bring up  UART2 in the Tiva C lauchpad:

I'm not using interrupts, is just a simple UART config.

Code:

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.c"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"


#define GPIO_PD6_U2RX           0x00031801
#define GPIO_PD7_U2TX           0x00031C01
#define GPIO_PA0_U0RX           0x00000001
#define GPIO_PA1_U0TX           0x00000401
#define BAUD                    38400

//*****************************************************************************

//*****************************************************************************
//
// UART config
//
//*****************************************************************************
void
ConfigureUART(void)
{

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    GPIOPinConfigure(GPIO_PA0_U0RX);
    GPIOPinConfigure(GPIO_PA1_U0TX);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    UARTStdioConfig(0, BAUD, 16000000);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
    GPIOPinConfigure(GPIO_PD6_U2RX);
    GPIOPinConfigure(GPIO_PD7_U2TX);
    GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    UARTClockSourceSet(UART2_BASE, UART_CLOCK_PIOSC);
    UARTStdioConfig(2, BAUD, 16000000);

}
//*****************************************************************************
// Main function
//*****************************************************************************
int
main(void)
{
    ConfigureUART();                       // UART Config

    while(1) {


        UARTCharPutNonBlocking(UART2_BASE, 'H');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART2_BASE, 'e');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART2_BASE, 'l');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART2_BASE, 'l');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART2_BASE, 'o');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART2_BASE, '\n');
        UARTCharPutNonBlocking(UART2_BASE, '\r');


        UARTCharPutNonBlocking(UART0_BASE, 'H');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART0_BASE, 'e');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART0_BASE, 'l');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART0_BASE, 'l');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART0_BASE, 'o');
        SysCtlDelay(SysCtlClockGet() / 10 / 3);
        UARTCharPutNonBlocking(UART0_BASE, '\n');
        UARTCharPutNonBlocking(UART0_BASE, '\r');
    }
}

 Problems:

I needed to place the defines:

#define GPIO_PD6_U2RX           0x00031801
#define GPIO_PD7_U2TX           0x00031C01
#define GPIO_PA0_U0RX           0x00000001
#define GPIO_PA1_U0TX           0x00000401

otherwise the code does not compile due to the error:

#20"identifier GPIO_PA0_U0RX is undefined"
(repeats the message for PA1, PD6 and PD7)

Despite of that, the UART0 is running fine, but when I probe the UART2, nothing comes out.(I'm using an osciloscope to probe the signal on PD7).

Did I miss something?

  • Mateus Morel said:
    Did I miss something?

    You very well may have mon ami - you very well may have.     Have you strong magnification - and the time/willingness to "comb thru" the GPIO section of your MCU manual.   (insure you're not at all tired)    With luck - and squinting - and acute awareness - somewhere - buried in the "mice type" - appears the caution/alert that PF0 and PD7 have received (unwanted) promotion to a (most always) "never to be used" function - and are thus unavailable to those 95%+ of (normal) users!    How delightful.

    If willing to search the forum you'll encounter (easily) hundreds of such cases - all becalmed, frustrated & delayed - just as you are!    And with enough (extra) time/effort - you'll learn about the "unlocking mechanism" - which vendor has decided is, "for users' own good."   (i.e. save us from ourselves)

    There's faster, simpler work-around - run like krazy away from any usage of PF0 or PD7!    All but those two (chosen) pins escape this vendor's "special delight."

  • Hi Morel,
    Right click on the project, go to Build -> ARM Compiler -> Advanced options -> Predefined Symbols , there under PRE DEFINE NAME, click the add icon,then in prompted window type the following "PART_TM4C123GH6PM"

    This could replace that line
  • Haresh G said:
    This could replace that line

    Really - and will that action, "break" the locked default of poster's PD7 pin?