Connection GPS UP501 FASTRAX

Discussion in 'Embedded Systems and Microcontrollers' started by Robert87, Mar 24, 2016.

  1. Robert87

    Thread Starter New Member

    Oct 12, 2015
    3
    0
    Hello everyone,
    I have an electric board with a MK10 of Freescale microcontroller and a GPS Fastrax UP501.
    The connection to the GPS is using the UART.
    I wrote the following code to handle the writing and reading dall'UART.

    Code (Text):
    1.  
    2. char SET_NMEA_OUTPUT[ ] = "$PMTK314,1,1,1,1,1,5,1,1,1,1,1,1,0,1,1,1,1,1,1*2C";
    3. char NMEA_UPDATE_5HZ[ ] = "$PMTK300,200,0,0,0,0*2F";
    4. char NMEA_BAUD_RATE[ ] = "$PMTK251,9600*27";
    5. char NMEA_start_mess[ ] = "$PMTK010,001*2E";
    6.  
    7. volatile char *a1=NMEA_UPDATE_5HZ;
    8. volatile char *a2=NMEA_BAUD_RATE;
    9. volatile char *a3=SET_NMEA_OUTPUT;
    10. volatile char *a4=NMEA_start_mess;
    11.  
    12. int set=0;
    13.  
    14. static UART_Type * const uart_reg[] = { UART0, UART1, UART2, UART3, UART4 };
    15.  
    16. static void process_irq(uint8_t dev) {
    17.    UART_Type *uart = uart_reg[dev];
    18.    bool write = true;
    19.    if (uart->S1 & UART_S1_TDRE_MASK) {
    20.      if (write){
    21.      switch (set){
    22.        case 0:
    23.            if (*a1 != '\0')
    24.            {
    25.              uart->D=*a1;
    26.              a1++;
    27.              break;
    28.  
    29.            }
    30.            else set=1;
    31.            break;
    32.        case 1:
    33.            if (*a2 != '\0')
    34.            {
    35.              uart->D=*a2;
    36.              a2++;
    37.              break;
    38.            }
    39.            else set=2;
    40.            break;
    41.        case 2:
    42.            if (*a3 != '\0')
    43.            {
    44.            uart->D=*a3;
    45.            a3++;
    46.            break;
    47.            }
    48.            else set=3;
    49.            break;
    50.        case 3:
    51.            if (*a4 != '\0')
    52.            {
    53.            uart->D=*a4;
    54.            a4++;
    55.            break;
    56.            }
    57.        }
    58.      }
    59.  
    60.      else write = false;
    61.    }
    62.  
    63.      else {
    64.        uart->C2 &= ~UART_C2_TIE_MASK;  // disable tx interrupt
    65.        uart->C2 |= UART_C2_RIE_MASK;
    66.      }
    67.  
    68.    if (uart->S1 & UART_S1_RDRF_MASK) {
    69.      //(void)uart->D;
    70.      //*data++ = uart->D;
    71.      printf("%c",uart->D);
    72.      }
    73. }
    74.  
    75.  


    As you can see the first thing I'm going to set the GPS on the basis of the commands in this manual:
    http://cdn.sparkfun.com/datasheets/Sensors/GPS/NMEA manual for Fastrax IT500 Series GPS receivers_V1.7.pdf


    I did not build arrays for reading but mold at random because I wanted to make a first test to see if it worked.
    But the GPS does not work. I see only the characters: $ and, (comma)
    Someone has used it?
    Is wrong code or commands the NMEA sentence?

    Thanks for any help
     
Loading...