Extracting data from gps

Tips and questions relating to the GPS modules from SFE
Locked
ryan
Posts: 36
Joined: Fri Sep 30, 2005 11:25 am

Extracting data from gps

Post by ryan » Thu Mar 22, 2007 5:56 am

I want to extract RMC RMB and GGA sentences from GPS using PIC16F877.But i am unable to recieve data using serial interrupt.GPS is working properly.
here is the CCS code.

Code: Select all

#include <lcd.h>
#include <420_lcdd.c>

#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7, stream=GPS)
unsigned int index=0;
unsigned char c;
unsigned char inStr[80] ;

 #INT_RDA
 void gps_isr(void)
  {
   c =fgetc(GPS);
   c = (char)c;

   if(c=='$')

      index=0;
      inStr[index]=c;
      index++;
      if((c==10)||(c==13))
      {
       inStr[index]='\0';
       index=0;
      }
}
void main()
{
    lcd_init();
    enable_interrupts(INT_RDA); 
    enable_interrupts(GLOBAL); 
    printf(lcd_putc,"\%s",inStr);
   WHILE(TRUE)
    {

    }


}

oPossum
Posts: 94
Joined: Thu Mar 30, 2006 4:58 pm
Location: Michigan, USA

Post by oPossum » Thu Mar 22, 2007 9:55 pm

Code: Select all

#include <lcd.h> 
#include <420_lcdd.c> 

#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7, stream=GPS) 
unsigned int index=0; 
char c; 
char inStr[2][80]; 
unsigned char sbuf=0; 
unsigned char last_sbuf=0; 

#INT_RDA 
void gps_isr(void) 
{ 
	c = fgetc(GPS); 

	if(c=='$')
		index=0;

	if(c=='\r' || c=='\n') 
	{ 
		inStr[sbuf&1][index]='\0'; 
		index=0; 
		++sbuf; 
	} else if(index<79) 
		inStr[sbuf&1][index++]=c; 
}

void main() 
{ 
   lcd_init(); 
   enable_interrupts(INT_RDA); 
   enable_interrupts(GLOBAL); 
   while(TRUE) 
   { 
      while(sbuf!=last_sbuf) { 
         printf(lcd_putc,"%s\n",inStr[last_sbuf&1]); 
         ++last_sbuf; 
      } 
   } 
}

ryan
Posts: 36
Joined: Fri Sep 30, 2005 11:25 am

Post by ryan » Fri Mar 23, 2007 1:21 am

Thnx... but nothing is displayed on the lcd. and the array inStr [2][80] takes toooo much RAM.

Locked

Return to “GPS”