GSM INTERFACING THROUGH SERIAL + LCD
#include <REGX51.H>
#define MYDATA P2
sbit rs=P3^2;
sbit rw=P3^3;
sbit en=P3^4;
unsigned char rval[76];
int fl=0;
void Delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
int ldata;
void lcdcmd(unsigned char value)
{
ldata = value;
rs = 0;
rw = 0;
en = 1;
Delay(5);
en = 0;
return;
}
void lcddata(unsigned char value)
{
ldata = value;
rs = 1;
rw = 0;
en = 1;
Delay(5);
en = 0;
return;
}
void lcdinit()
{
lcdcmd(0x03);
lcdcmd(0x0c);
lcdcmd(0x01);
lcdcmd(0x80);
}
void init()
{
SCON=0x50;
TMOD=0X20;
TH1=0XFD;
TR1=1;
lcdinit();
}
void txs(unsigned char value)
{
TI=0;
SBUF=value;
while(TI==0);
}
void disp(unsigned char val)
{
lcddata(val);
}
void welcome()
{
lcdcmd(0x80);
disp('W'); disp('e');disp('l'); disp('c');disp('o'); disp('m');disp('e'); disp(' ');
}
unsigned char rxs()
{
unsigned int c=0;
while(RI==0)
{
if(fl==0)
{
if(P1_7==0)
{
}
}
c++;
if(c>40000)
break;
}
RI=0;
return SBUF;
}
void rxmo()
{
char i;
txs('A');txs('T');txs('+');txs('C');txs('M');txs(' G');
txs('R');txs('=');txs('1');txs(13);
for(i=0;i<76;i++)
{
P1_6=!P1_6;
rval[i]=rxs();
}
}
void del1()
{
char i;
txs('A');txs('T');txs('+');txs('C');txs('M');txs(' G');
txs('D');txs('=');txs('1');txs(13);
for(i=0;i<13;i++)
{
P1_5=!P1_5;
rval[i]=rxs();
}
}
void main()
{
unsigned char i=0,oc=0;
init();
txs('A');txs('T');txs('+');txs('I');txs('F');txs(' C');
txs('=');txs('0');txs(',');txs('0');txs(13);
txs('A');txs('T');txs(13);
txs('A');txs('T');txs('+');txs('C');txs('M');txs(' G');
txs('F');txs('=');txs('1');txs(13);
del1();
welcome();
while(1)
{
rxmo();
lcdcmd(0xc0);
for(i=72;i<=75;i++)
{
lcddata(rval[i]);
}
}
}
the gsm modem is recieving the messages only one at a time and displaying if we send another the previous message is not marking as unread please do the need full.
GSM AND GPS INTERFACING: