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.

CCS/TM4C1294NCPDT: Problem with uart transmitting to gps sensor

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Hello,

I am trying to use the UART0 interface with the tm4c129 launchpad to connect with the venus gps sensor from sparkfun. I can receive data every time but i cannot send commands to limit what data I want to actually get every time. Below is the uart code i have written that has worked with receiving. I also get an overrun error when i do receive data from this interrupt process as well. Any advice or help would be greatly appreciated!

www.sparkfun.com/.../Skytraq-Venus634FLPx_DS_v051.pdf this is the data sheet, and this is the binary commands for the sensor www.sparkfun.com/.../AN0003_v1.4.14_FlashOnly.pdf

below is my code thus far.


#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "inc/hw_ints.h"
#include "driverlib/interrupt.h"

uint32_t ui32SysClkFreq;
int y;
char *token;
char c = '0';
char data[80];
int count = 0;
unsigned char rate[17] = {0xA0,0xA1,0x00,0x09,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x0D,0x0A};
unsigned char gga[16] = {0xA0,0xA1,0x00,0x09,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x0D,0xA0};
uint32_t num = 120000;
uint32_t delay = 102888;
void sendChar();

int main(void)
{
    ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_UART0))
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_SYSTEM);
    GPIOPinConfigure(GPIO_PA0_U0RX);
    GPIOPinConfigure(GPIO_PA1_U0TX);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    UARTFIFODisable(UART0_BASE);
    UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_FIFO);
    UARTConfigSetExpClk(UART0_BASE, ui32SysClkFreq, 9600,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
    UARTFIFOEnable(UART0_BASE);
    UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_FIFO);
    UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);

    IntMasterEnable();
    IntEnable(INT_UART0);
    UARTRxErrorClear(UART0_BASE);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_OE | UART_INT_RT);

}
/*void sendChar()
{
    unsigned int y;
    for(x=0;x<10;x++)
    {
    while(UARTBusy(UART0_BASE));
    UARTCharPut(UART0_BASE,rate[x]);
    SysCtlDelay(100);
    x++;
    */



void UARTIntHandler(void)
{
    uint32_t ui32Status;
    ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
    UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupt
    while(UARTCharsAvail(UART0_BASE)) //loop while there are chars
    {
        for(y=0;y<16;y++)
            {
            while(UARTBusy(UART0_BASE));
            UARTCharPut(UART0_BASE,gga[15]);
                y++;
            }

            if(count<80)
                    {

                    //SysCtlDelay(delay);
                    data[count] = UARTCharGet(UART0_BASE);
                    //SysCtlDelay(delay);
                    count++;

                    }
            if(count==80)
            {
                UARTDisable(UART0_BASE);

            }


    }
}

  • John,
    First, please when posting code, use the identing option on the Rich Formatting interface (the </> icon). It is difficult to visualize your code as posted.
    As for your difficult (and maybe the confusing visualization is not helping here), are you really sending a command via Uart0 every time a interrupt occurs? That means that for each byte that comes in, you'd send 16 bytes out? Configuration commands are usually sent just once to an external device.
    Why are you turning off UART when your income buffer is full? Even if you are receiving one GPS message per second, you will want to process the next location one second later. You need to parse your message, deal with the values and keep moving on.
    Cheers
    Bruno
  • As Bruno pointed out, you don't want to be transmitting 16 times the value 0xA0 each time you receive a character. If the purpose of that transmission is to configure the NMEA messages disabling all of the standard messages except GGA, that loop should be called from main, not in the interrupt routine and you need to index through the array as you transmit. Finally the CheckSum byte should be 0x09 not 0x08 (0x08 ^ 0x01), and the last character of that string should be 0x0A, not 0xA0

    The second reason you are getting the receive overflow is that you never reset your count back to zero. When I did a NMEA0183 application, in the UART interrupt handler, I would check the received character for LF (0x0A) and identify that as the end of the string. Then I would set a flag that would be checked in the main routine, and the main routine would process the NMEA string. I used a circular buffer for receiving the strings, but a simpler implementation would be to allocate two 80 character strings and ping pong between them. Let the interrupt handler fill one while the main routine processes the sentence received in the other.