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.
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
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:
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";
char NMEA_UPDATE_5HZ[ ] = "$PMTK300,200,0,0,0,0*2F";
char NMEA_BAUD_RATE[ ] = "$PMTK251,9600*27";
char NMEA_start_mess[ ] = "$PMTK010,001*2E";
volatile char *a1=NMEA_UPDATE_5HZ;
volatile char *a2=NMEA_BAUD_RATE;
volatile char *a3=SET_NMEA_OUTPUT;
volatile char *a4=NMEA_start_mess;
int set=0;
static UART_Type * const uart_reg[] = { UART0, UART1, UART2, UART3, UART4 };
static void process_irq(uint8_t dev) {
UART_Type *uart = uart_reg[dev];
bool write = true;
if (uart->S1 & UART_S1_TDRE_MASK) {
if (write){
switch (set){
case 0:
if (*a1 != '\0')
{
uart->D=*a1;
a1++;
break;
}
else set=1;
break;
case 1:
if (*a2 != '\0')
{
uart->D=*a2;
a2++;
break;
}
else set=2;
break;
case 2:
if (*a3 != '\0')
{
uart->D=*a3;
a3++;
break;
}
else set=3;
break;
case 3:
if (*a4 != '\0')
{
uart->D=*a4;
a4++;
break;
}
}
}
else write = false;
}
else {
uart->C2 &= ~UART_C2_TIE_MASK; // disable tx interrupt
uart->C2 |= UART_C2_RIE_MASK;
}
if (uart->S1 & UART_S1_RDRF_MASK) {
//(void)uart->D;
//*data++ = uart->D;
printf("%c",uart->D);
}
}
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