Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/27/09 04:23
Read: times


 
Msg Score: -1
 -1 Didn't Search First
#170081 - c code help for GPS interfacing

..#include"89c51.h"
#define c=17;
unsigned char j=0;
unsigned char a[10];
unsigned char i=1;
unsigned char temp1;
unsigned char temp2;
unsigned char mybyte;
unsigned char temp3;
unsigned char temp4;
unsigned char temp5;
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void lcdready();
void MSdelay(unsigned char);
sfr ldata = 0x90;
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
sbit busy = P1^7;
unsigned char k;



void serial(void)interrupt 4
{
  if(RI==1)											 

  {
    i++;
		if(i==254)
	{
	  i=1;
	}
  	mybyte=SBUF;
	
	if(mybyte=='R')
	{
	  temp1=i;
	  temp2=temp1+c;
	  temp3=temp2+1;
	  temp4=temp3+9;
	  temp5=temp4+1;

	}
	RI=0;
  }
}
void main(void)
{
  SCON=0x50;
  TMOD=0x20;
  TH1=0xFD;
  EA=1;
  ES=1;
  TR1=1;
  while(1)
  {
 
	if(i==temp2)
	{
	  a[j]=mybyte;
	  j++;
	  temp2=0;
	}
	if(i==temp3)
	{
	  a[j]=mybyte;
	  j++;
	  temp3=0;
	}
	 
  	if(i==temp4)
	{
	  a[j]=mybyte;
	  j++;
	  k=j;
	  temp4=0;
	}
	
  	if(i==temp5)
	{
	  a[j]=mybyte;
	  lcdcmd(0x38);																	 
      lcdcmd(0x0C);
	  lcddata('L');
	  lcddata('A');
	  lcddata('T');
	  lcddata('=');
	  for(j=0;j<=k;j++)
	  {
	  	lcddata(a[j]);
	  }
	  lcdcmd(0x02);
	  lcdcmd(0x08);
	  /*
	   MSdelay(40);
       lcdcmd(0x01);
       MSdelay(40);
	   lcdcmd(0x08);     
	   j=0;
	   temp5=0;*/
	}
   
  }
 
}
void lcdcmd(unsigned char value)
{
   lcdready();
   ldata=value;
   rs=0;
   rw=0;
   en=1;
   en=0;
}
void lcddata(unsigned char value)
{
  lcdready();
  ldata=value;
  rs=1;
  rw=0;
  en=1;
  en=0;
} 
void lcdready()
{
  busy=1;
  rs=0;
  rw=1;
  while(busy==1)
  {
     en=0;
	 MSdelay(2);
	 en=1;
  }
}
void MSdelay(unsigned char time)
{
 unsigned char i;
  for(i=0;i<time;i++)
  {
   TMOD=0x01;
   TL0=0xFD;
   TH0=0x4B;
   TR0=1;
   while(TF0==0);
   TR0=0;
   TF0=0;
  }
}
 


I have made this code on keil compiler for displaying only latitude value after getting RMC message.
but i am facing some problem on second part in LCD to display longitude in another line.
Is my above code is correct?



List of 2 messages in thread
TopicAuthorDate
c code help for GPS interfacing            01/01/70 00:00      
   What do you think?            01/01/70 00:00      

Back to Subject List