O
omar.nasir123
Guest
Hi, im trying to serially interface sim548c module with microcontroller 89c52. i have successfully sent AT commands via TX of microcontroller to RX of GSM part of sim 548c module. As soon as the commands are sent, i want to immediately start receiving the replies from the GSM part via RX of microcontroller. The replies are stored in a char array and then checked to see whether the AT command was successfully passed. The problem is each time when i output my array it gives null value (it is not storing anything). Here is my code. can anyone please identify the problem in it?
in the main function im passing all AT commands like this:
compare("EHLO lavabit.com","250");
250 is the status code that is replied if the command is succesfully to the lavabit server. I have already established gprs sessions with the server. If i try to output info array during search function it gives zeros and because nothing is storing in it, the control remains in the compare function and the same command is sent over and over again.
Code:
int check=0;
int out=0;
unsigned char info[20]={"00000000000000000000"};
unsigned char *s;
unsigned char a[3],b[3];
void transmit_data(unsigned char str)
{
SBUF=str;
while(TI==0);
TI=0;
}
void send_serial(unsigned char *s)
{
delay(50);
while(*s!=0x0)
{
SBUF=*s;
while(TI==0)
{
}
TI=0;
s++;
}
}
void receive_data() interrupt 4
{
if(RI)
{
info[check++]=SBUF;
RI=0;
}
if(TI)
TI=0;
}
void search(unsigned char b[])
{
int l=0;
for(l;l<18;l++)
{
if(info[l]==b[0] && info[l+1]==b[1] && info[l+2]==b[2])
{
out=1;
break;
}
}
}
void compare(unsigned char *s, unsigned char a[]) //for CIPSEND
{
while(1)
{
out=0;
check=0;
delay(50);
send_serial("AT+CIPSEND\r");
delay(100);
send_serial(s);
transmit_data(0x0D);
transmit_data(0x0A);
transmit_data(0x1A);
IE=0x90;
delay(200);
IE=0x88;
search(a);
if (out==1)
break;
}
}
Use CODE tags when posting your code
in the main function im passing all AT commands like this:
compare("EHLO lavabit.com","250");
250 is the status code that is replied if the command is succesfully to the lavabit server. I have already established gprs sessions with the server. If i try to output info array during search function it gives zeros and because nothing is storing in it, the control remains in the compare function and the same command is sent over and over again.
Last edited by a moderator: