zelin
Newbie level 3
hi guys i am trying to extract a message from t290 and store its contents into 8951. the code i have written works fine with hyper terminal (using serial communication). how ever for mobile communication i need to do following
for hyper terminals pin configuration
14 pin max232 --> 2 pin of port
13 pin max232 --> 3 pin of port
for mobile terminal pin configuration
14 pin max232 --> 3 pin of port
13 pin max232 --> 2 pin of port
inverse pin configuration
NOW the code i have written is this
--------------------------------------------
#include<reg51.h>
sbit q=P1^0;
sbit w=P1^1;
sbit e=P1^2;
sbit r=P1^3;
sbit t=P1^4;
//************** FUNCTION TO SEND THE CHARACTER STRING ************
void sendString(unsigned char *a)
{
while(*a!='\0')
{
SBUF=*a;// SBUF is register used to send/receive data serially
while(TI==0);
TI=0; //transmit Flag.
a++;
}
}
//************** FUNCTION TO SEND SINGLE CHARACTER ************
void sendChar(unsigned char cool.gif
{
SBUF=b;
while(TI==0);
TI=0;
}
//---------------------------------------
void main (void)
{
unsigned int a;
unsigned char B[5];
for (a=0;a<=15;a++)
{
SBUF=0x55;
while(TI==0);
TI=0;
}
TMOD=0x20;
TH1 =0xFD;
SCON=0x50;
TR1=1;
q=0;
sendString("AT");
sendChar(0x0d);
sendChar(0x0A);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
//----------------------------------------------------------
sendString("AT+CMGF=1"); // to select text mode
sendChar(0x0d);
sendChar(0x0A);
w=1;
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
//----------------------------------------------------------
sendString("AT+CPMS=");
sendChar(0x22); //0x22="
sendString("ME"); //to select phone memory
sendChar(0x22);
sendChar(0x0d);
sendChar(0x0A);
//----------------------------------------------------------
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
e=0;
//----------------------------------------------------------
sendString("AT+CMGL=");
sendChar(0x22); //0x22="
sendString("ALL"); //to select phone memory
sendChar(0x22);
sendChar(0x0d);
sendChar(0x0A);
r=1;
//----------------------------------------------------------
for(a=0;a<=5;a++)
{
B[a]= SBUF;
while(RI==0);
RI=0;
}
for(a=0;a<30000;a++);
while(1)
{
t=0;
P0=B[1];
P2=B[0];
}
}
//************
this code works fine with hyper terminal i get this output
AT
AT+CMGF=1
AT+CPMS="ME"
AT+CMGL="ALL"
now on mobile when i run this code my port 1 bits changed i-e i reach upto r=1 <pin 3 of port 1 changes to 1 >
but here is the problem
the while loop doesn't seem to work........ i nvr get t=0; if anyone can help how can i retrieve the sms from mobile ... would be grateful over that.
regards
for hyper terminals pin configuration
14 pin max232 --> 2 pin of port
13 pin max232 --> 3 pin of port
for mobile terminal pin configuration
14 pin max232 --> 3 pin of port
13 pin max232 --> 2 pin of port
inverse pin configuration
NOW the code i have written is this
--------------------------------------------
#include<reg51.h>
sbit q=P1^0;
sbit w=P1^1;
sbit e=P1^2;
sbit r=P1^3;
sbit t=P1^4;
//************** FUNCTION TO SEND THE CHARACTER STRING ************
void sendString(unsigned char *a)
{
while(*a!='\0')
{
SBUF=*a;// SBUF is register used to send/receive data serially
while(TI==0);
TI=0; //transmit Flag.
a++;
}
}
//************** FUNCTION TO SEND SINGLE CHARACTER ************
void sendChar(unsigned char cool.gif
{
SBUF=b;
while(TI==0);
TI=0;
}
//---------------------------------------
void main (void)
{
unsigned int a;
unsigned char B[5];
for (a=0;a<=15;a++)
{
SBUF=0x55;
while(TI==0);
TI=0;
}
TMOD=0x20;
TH1 =0xFD;
SCON=0x50;
TR1=1;
q=0;
sendString("AT");
sendChar(0x0d);
sendChar(0x0A);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
//----------------------------------------------------------
sendString("AT+CMGF=1"); // to select text mode
sendChar(0x0d);
sendChar(0x0A);
w=1;
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
//----------------------------------------------------------
sendString("AT+CPMS=");
sendChar(0x22); //0x22="
sendString("ME"); //to select phone memory
sendChar(0x22);
sendChar(0x0d);
sendChar(0x0A);
//----------------------------------------------------------
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
for(a=0;a<30000;a++);
e=0;
//----------------------------------------------------------
sendString("AT+CMGL=");
sendChar(0x22); //0x22="
sendString("ALL"); //to select phone memory
sendChar(0x22);
sendChar(0x0d);
sendChar(0x0A);
r=1;
//----------------------------------------------------------
for(a=0;a<=5;a++)
{
B[a]= SBUF;
while(RI==0);
RI=0;
}
for(a=0;a<30000;a++);
while(1)
{
t=0;
P0=B[1];
P2=B[0];
}
}
//************
this code works fine with hyper terminal i get this output
AT
AT+CMGF=1
AT+CPMS="ME"
AT+CMGL="ALL"
now on mobile when i run this code my port 1 bits changed i-e i reach upto r=1 <pin 3 of port 1 changes to 1 >
but here is the problem
the while loop doesn't seem to work........ i nvr get t=0; if anyone can help how can i retrieve the sms from mobile ... would be grateful over that.
regards