cllunlu
Member level 4
siemens c55 problem tx rx
hi friends.
I am trying to send sms with 8051(89c51rc2)and siemens C55.But I failed.I dont know why.When I try to send sms,cellphone turns off.
My schematic and C code here.where is my mistake.I dont know.
Also I can send sms by hyperterminal with data cable.And I simulated it by proteus succesfully.And it is project to pass the class.Plz help me firends.
/////////////////////////////////////////////////////////////////////////
that is my schematic:
https://obrazki.elektroda.pl/10_1208886865.jpg
that is C code:
///////////////////////////////////////////////////////////////////////////
#include <t89c51Rx2.h>
unsigned char rcvd[2];
unsigned char j;
unsigned char k;
bit ok=0;
bit ok1=0;
void init() /// u put int() here
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
void sendString(unsigned char *a)
{
while(*a!='\0')
{
SBUF=*a;
while(TI==0);
TI=0;
a++;
}
}
void sendChar(unsigned char b)
{
SBUF=b;
while(TI==0);
TI=0;
}
unsigned char rcv()
{
while(RI==0);
RI=0;
return SBUF;
}
void checkOK()
{
for(j=0;j<2;j++)
rcvd[j]=rcv();
if(rcvd[0]=='o'&&rcvd[1]=='k')
ok=1;
else
ok=0;
}
void checkOKe()
{
k=rcv();
if(k=='>')
ok1=1;
else
ok1=0;
}
void main()
{
P2_0=0;
P2_1=0;
while(1)
{
if(P1_0==0)
{
init();
sendString("AT");
sendChar(0x0D);
checkOK();
if(ok==1)
{
P2_0=1;
sendString("AT+CMGS=19");
sendChar(0x0D);
checkOKe();
if(ok1==1)
{
P2_1=1;
sendString("079109459208003311000C910945664173350000AA05E8329BFD06");
//sms center no:+905429800033, destination number:+905466143753, message:"HELLO"
sendChar(0x1A);
}
else P2_1=0;
}
else
P2_0=0;
}
}
}
hi friends.
I am trying to send sms with 8051(89c51rc2)and siemens C55.But I failed.I dont know why.When I try to send sms,cellphone turns off.
My schematic and C code here.where is my mistake.I dont know.
Also I can send sms by hyperterminal with data cable.And I simulated it by proteus succesfully.And it is project to pass the class.Plz help me firends.
/////////////////////////////////////////////////////////////////////////
that is my schematic:
https://obrazki.elektroda.pl/10_1208886865.jpg
that is C code:
///////////////////////////////////////////////////////////////////////////
#include <t89c51Rx2.h>
unsigned char rcvd[2];
unsigned char j;
unsigned char k;
bit ok=0;
bit ok1=0;
void init() /// u put int() here
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
void sendString(unsigned char *a)
{
while(*a!='\0')
{
SBUF=*a;
while(TI==0);
TI=0;
a++;
}
}
void sendChar(unsigned char b)
{
SBUF=b;
while(TI==0);
TI=0;
}
unsigned char rcv()
{
while(RI==0);
RI=0;
return SBUF;
}
void checkOK()
{
for(j=0;j<2;j++)
rcvd[j]=rcv();
if(rcvd[0]=='o'&&rcvd[1]=='k')
ok=1;
else
ok=0;
}
void checkOKe()
{
k=rcv();
if(k=='>')
ok1=1;
else
ok1=0;
}
void main()
{
P2_0=0;
P2_1=0;
while(1)
{
if(P1_0==0)
{
init();
sendString("AT");
sendChar(0x0D);
checkOK();
if(ok==1)
{
P2_0=1;
sendString("AT+CMGS=19");
sendChar(0x0D);
checkOKe();
if(ok1==1)
{
P2_1=1;
sendString("079109459208003311000C910945664173350000AA05E8329BFD06");
//sms center no:+905429800033, destination number:+905466143753, message:"HELLO"
sendChar(0x1A);
}
else P2_1=0;
}
else
P2_0=0;
}
}
}