SparkFun Forums 

Where electronics enthusiasts find answers.

Tips and questions relating to the GPS modules from SFE
By ryan
#27607
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)
    {

    }


}
By oPossum
#27657
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; 
      } 
   } 
}
By ryan
#27664
Thnx... but nothing is displayed on the lcd. and the array inStr [2][80] takes toooo much RAM.