I am using a TM4C129EXL Tiva-C launchpad and I am facing difficulty in reading the data from the RX and TX pins which are connected to a NEO-6M GPS module.
The NEO-6M led indication shows that Position has been fixed, but I am not able to display the data in Code composer Studio(CCS) console.
Pin connection:
NEO6M RX -----> PA7 UART2 TX of MCU
NEO6M TX -----> PA6 UART2 RX of MCU
NEO6M Vcc -----> +5v of MCU
NEO6M GND ------> GND of MCU
Code:
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "drivers/pinout.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
uint32_t g_ui32SysClock;
char charBuffer[128];
uint8_t *charHolder;
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
void
ConfigureUART(void)
{
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// wait till port A is ready.
while(!ROM_SysCtlPeripheralReady){}
// setting the pins
ROM_GPIOPinConfigure(GPIO_PA6_U2RX);
ROM_GPIOPinConfigure(GPIO_PA7_U2TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
// wait till the peripheral is ready
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_UART2)){}
// configuring the UART with baud rate 9600
ROM_UARTConfigSetExpClk(UART2_BASE,g_ui32SysClock,9600,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
ROM_UARTEnable(UART2_BASE);
}
void UARTIntHandler(void){
}
int
main(void)
{
//
// Run from the PLL at 120 MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet(false, false);
ConfigureUART();
while(1)
{
if(UARTCharsAvail(UART2_BASE)){
UARTprintf((char*)UARTCharGetNonBlocking(UART2_BASE));
}else{
UARTprintf("hello world\n");
}
}
}