As I am new to microcontrollers in general, I am trying to use UART2 to communicate with a GPS and show the data on the PC through UART0 (usb cable provided with the microcontroller). But I don't receive anything on UART2 for whatever reason. The hardware setup is like shown below on the screenshot. The code is also provided below
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
#include "driverlib/pin_map.h"
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinConfigure(GPIO_PD6_U2RX);
GPIOPinConfigure(GPIO_PD7_U2TX);
GPIOUnlockPin(GPIO_PORTD_BASE, GPIO_PIN_7);
GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7);
UARTConfigSetExpClk(UART2_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
UARTCharPut(UART0_BASE, 'T');
UARTCharPut(UART0_BASE, 'E');
UARTCharPut(UART0_BASE, 'S');
UARTCharPut(UART0_BASE, 'T');
UARTCharPut(UART0_BASE, '\r');
UARTCharPut(UART0_BASE, '\n');
//uint8_t rxData = 0;
//UARTCharPut(UART0_BASE, UARTCharGet(UART2_BASE));
while (1)
{
if (UARTCharsAvail(UART2_BASE))
{
//rxData = UARTCharGet(UART2_BASE);
if (UARTCharsAvail(UART0_BASE))
{
UARTCharPut(UART0_BASE, UARTCharGet(UART2_BASE));
}
}
//UARTCharPut(UART0_BASE, rxData);
}
}