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.

MSP-EXP430FR2433: Receiving and Transmitting NMEA Packet from GPS receiver module

Part Number: MSP-EXP430FR2433


Hey, 

I am trying to receive a NMEA packet from a GPS module and transmit it to the a PC terminal via UART, is there any open source library already available, or any reference to start with.

Thanks

  • Library to do what?

    It really depends on what you want to do. If you are just retransmitting the echo examples will fill the bill.

    You can check out some of the arduino libraries like TinyGPS, they should be easily portable to the MSP430.

  • I want to receive the NMEA packets coming from the GPS module and transmit it to the PC, thanks!

  • Also, because the MSP430 chip I have has two UART communicators ( Pin 1.4,1.5 and Pin 2.5,2.6) I want the GPS module to transmit to Pin 2.5 then transmit from Pin 2.6 to Pin 1.5 then transmit from Pin 1.4 to the PC. 

  • If you don't plan on doing any parsing, then just look at the uart echo examples for your mcu in Resource Explorer.

    You just need to change the UARTS accordingly.

  • yes i've managed to echo the nmea packets from Port 2 to port 1, I do need to do parsing, was wondering if there is any examples of parsing the nmea code

  • Check out TinyGPS, it is for the arduino, but should be easily ported.

  • I am having problems with my code, I dont see any ouput from the COM, I am receiving data from the GPS module, and sending it though the micro usb to the PC, I have removed the RX jumper as well. When i step through it stops at ''char line[BUFFER_SIZE]; // Buffer to hold GPS raw string''. 

    #include "msp430.h"
    #include <string.h>
    #include "driverlib.h"

    // rev 1.5
    #define RXD BIT5
    #define TXD BIT4

    int BUFFER_SIZE = 300;

    void setup(){
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

    // Configure GPIO
    //Init_GPIO();
    PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
    // to activate 1previously configured port settings

    __bis_SR_register(SCG0); // disable FLL
    CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
    CSCTL1 = DCOFTRIMEN | DCOFTRIM0 | DCOFTRIM1 | DCORSEL_3;// DCOFTRIM=3, DCO Range = 8MHz
    CSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz
    __delay_cycles(3);
    __bic_SR_register(SCG0); // enable FLL
    //Software_Trim(); // Software Trim to get the best DCOFTRIM value

    CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
    // default DCODIV as MCLK and SMCLK source

    // Configure UART pins
    P1SEL0 |= BIT4 | BIT5; // set 2-UART pin as second function

    // Configure UART
    UCA0CTLW0 |= UCSWRST;
    UCA0CTLW0 |= UCSSEL__SMCLK;

    // Baud Rate calculation
    // 8000000/(16*9600) = 52.083
    // Fractional portion = 0.083
    // User's Guide Table 14-4: UCBRSx = 0x49
    // UCBRFx = int ( (52.083-52)*16) = 1
    UCA0BR0 = 52; // 8000000/16/9600
    UCA0BR1 = 0x00;
    UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;

    UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
    UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

    __bis_SR_register(LPM3_bits|GIE); // Enter LPM3, interrupts enabled
    __no_operation(); // For debugger
    // Enable interrupts
    }

    // Accepts a character pointer to an array and prints in over serial
    void UART_TX(char * tx_data){
    unsigned int i=0;
    while(tx_data[i]){ // Increment through array, look for null pointer (0) at end of string
    while (!(UCA0IFG&UCTXIFG)); // Wait if line TX/RX module is busy with data
    UCA0TXBUF = tx_data[i]; // Send out element i of tx_data array on UART bus
    if (UCA0TXBUF == '\n'){ break; }
    i++; // Increment variable for array address
    }
    }


    void main(){
    char byteGPS = 1; // Current read byte
    char line[BUFFER_SIZE]; // Buffer to hold GPS raw string
    char fieldBuffer[80] = ""; // buffer to hold a field in GPS raw string
    int fieldLength = 0;
    char commandGPS[7] = "$GPGGA"; // String related to messages
    int commandLength = 6;
    int counter=0;
    int correctness=0;
    int lineCounter=0;
    int numOfFieldsInterested = 8; // the first n fields of interest in GPGGA message (refer to NMEA specification for details)
    int index[numOfFieldsInterested];

    setup();
    memset(line, 0, BUFFER_SIZE);

    while(1){
    // check if the board have recieved a new byte from GPS module
    if ((UCA0IFG & UCRXIFG)){
    byteGPS = UCA0RXBUF;

    line[lineCounter] = byteGPS; // put data read in the buffer
    lineCounter++;

    UCA0IFG &= ~UCRXIFG; // tell the board that we have read the byte

    // if the transmission has finished, start parsing
    if (byteGPS == '\n'){
    counter=0;
    correctness=0;
    // test if the received command starts by $GPGGA
    int i = 0;
    for (i =0 ; i < commandLength; i++){
    if (line[i] == commandGPS[i]){
    correctness++;
    }
    i = 0;
    }

    if (correctness==commandLength){
    int k = 0;
    while(line[k] && k < BUFFER_SIZE){
    if (line[k]==',' || line[k]=='*'){
    index[counter]=k;
    counter++;
    }
    k++;
    }

    UART_TX("GPS raw string: ");
    UART_TX(line); // transmit data to laptop

    for (i=0;i<numOfFieldsInterested;i++){
    fieldLength = index[i+1] - index[i] - 1;

    switch(i){
    case 0 :
    UART_TX("Time in UTC (HhMmSs): ");
    break;
    case 1 :
    UART_TX("Latitude: ");
    break;
    case 2 :
    UART_TX("Direction (N/S): ");
    break;
    case 3 :
    UART_TX("Longitude: ");
    break;
    case 4 :
    UART_TX("Direction (E/W): ");
    break;
    case 5:
    UART_TX("GPS Quality: ");
    break;
    case 6:
    UART_TX("Number of satellites used: ");
    break;
    default:
    continue;
    }

    strncpy(fieldBuffer, line+index[i]+1, fieldLength);
    UART_TX(fieldBuffer);
    UART_TX("\n");

    memset(fieldBuffer, 0, 80);
    }

    __delay_cycles(10000000); // delay for 10s before next transmission, the unit of delay_cycle is microsecond
    }

    lineCounter=0;
    }
    }
    }
    }

  • What is your stack size? You are trying to put 300 bytes on the stack. I suggest you make the buffer global, i.e., define it outside of main().

  • i increase my stack size to 300, and defined the buffer outside of the main loop, how would i incorporate the TinyGPS arduino library to my specific MSP430 device

  • By taking the source code and using the parts that make sense for your application. I always just write my own parser to pick out just the info I want. It is not that hard.

**Attention** This is a public forum