/************************* HEADER FILE *************************************/
#include<function.h>
/************************* MAIN FUNCTION **********************************/
void main()
{
unsigned char i,msg[50];
uartinit();
lcd_init();
while(1)
{
cmd(0x01);
lcd_datawrt("WAITING FOR MSG");//wait
while((getdat())!=':');
while((getdat())!='+');
while(getdat()!='\n');
for(i=0;i<20;i++)
{
msg=getdat();
if(msg=='\r')
break;
}
msg='\0';
lcd_datawrt(msg);
}
}
/***************************** END *************************************/
/************************* HEADER FILE *************************************/
#include<reg51.h>
#include<function.h>
/************************* LCD_PINS ***************************************/
sbit RS=P1^0;
sbit EN=P1^1;
/************************* FUNCTIONS *************************************/
void cmd(unsigned char cd)
{
unsigned int a,x;
a=(cd&0xF0)>>2;
RS=0;
P1=a;
RS=0;
EN=1;
delay(5);
EN=0;
P1=0X0;
delay(5);
x=((cd&0x0F)<<2);
P1=x;
RS=0;
EN=1;
delay(5);
EN=0;
P1=0X0;
//return;
}
void dat(unsigned char dt)
{
unsigned int a1,x1;
a1=(dt&0xF0)>>2;
P1=a1;
RS=1;
EN=1;
delay(5);
EN=0;
P1=0X0;
delay(5);
x1=((dt&0x0F)<<2);
P1=x1;
RS=1;
EN=1;
delay(5);
EN=0;
P1=0X0;
}
void lcd_datawrt(unsigned char *msg)
{
unsigned char count=0;
for(;*msg; msg++)
{
if(count>15)
cmd(0xc0);
if(count>31)
cmd(0x18);
dat(*msg);
count++;
}
}
void lcd_init()
{
unsigned char cmdarray[]={0x28,0x0C,0x01,0x06,0x80},t=0;
for (t=0;t<5;t++)
{
cmd(cmdarray[t]);
delay(10);
}
}
void uartinit(void) //uart initialising
{
TMOD=0x20;
TH1=0x0FD;//9600 baud rate
SCON=0x50;
TR1=1;
}
unsigned char getdat(void) //receive gps data serially
{
unsigned char a;
while(RI==0);
a=SBUF;
RI=0;
return(a);
}
void delay (unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<2000;j++);
return;
}
/***************************** END *************************************/