0

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");
        }
 
    }
}
  • 1
    If you are using CCS with a TI board then you have access to all of the internal debugging information. Single-stepping through your code and inspecting variables will be much more effective than staring at the source. – Elliot Alderson Mar 31 '21 at 12:23
  • thanks for this, this would help... And a question I had in mind do I have to enable the UART Interrupts? – Adithya Shetty Mar 31 '21 at 14:28
  • Do you need an interrupt service routine to run for any reason? If so then it needs to be enabled. Is it already enabled? Use CCS and check the values of the relevant registers. – Elliot Alderson Mar 31 '21 at 14:54

0 Answers0