here is a code for gps reception. if any error ask me here
void getgps(void)
{
unsigned char timeout = 50;
do
{
CREN = 0;
DelayMs(10);
CREN = 1;
while(getch() != '$')
{
}
#ifdef debug
puts("$ GOT");
#endif
/*GPS HEAD*/
i = 0;
gps_data = 0;
while(gps_data != ',')
{
gps_data = getch_timeout();
gps_head = gps_data;
i++;
}
#ifdef debug
puts("HEADER GOT");
#endif
if((gps_head[3] == 'G') &&(gps_head[4] == 'A'))
{
#ifdef debug
puts("GPGGA GOT");
#endif
GP_FLG = 1;
while(getch_timeout() != ',');
/*LATITUDE*/
i = 0;
gps_data = 0;
while(gps_data != ',')
{
gps_data = getch_timeout();
LAT = gps_data;
i++;
}
i--;
LAT = getch();
i++;
LAT = 0;
gps_data = getch_timeout();
#ifdef debug
puts("LAT GOT");
#endif
/*LONGITUDE*/
i = 0;
gps_data = 0;
while(gps_data != ',')
{
gps_data = getch_timeout();
LONG = gps_data;
i++;
}
i--;
LONG = getch_timeout();
i++;
LONG = 0;
#ifdef debug
puts("LONG GOT");
#endif
while(getch()!= 13)
{
timeout--;
}
}
}while(!GP_FLG);
return;
}