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?