16F877A Communication with SIM900

Status
Not open for further replies.

awabid

Newbie level 1
Joined
Feb 5, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
Hi Folks,

I am in a deep trouble. I am interfacing PIC16F877A with SIM900. I am working in PCWHD (CCS C), and running my PIC hardware on Proteus, and using SIM900 kit to be interfaced with PC through RS232 COM Port. I am trying to initialize the SIM900. For this purpose, I want to send ATE0, which is successful, and I get back OK. Then I want to send AT+CREG?. For simplicity, I sent AT. The response is OK, and I can read it through VIRTUAL TERMINAL of Proteus. If I send ATD command, the SIM responses perfectly and calls me. But here is the problem.

When I send OK, I want to read its response as well. The response can be OK or any other response. If it is OK, I want to then proceed further. For this purpose, I wrote a code like this:

void initialize_sim900(void){
char replies[10]="";
char garbage;
char rep_ok[5]="OK";
char rep_creg[] = "+CREG: 1,1";
int1 CallReady;
CallReady = 0;
printf("ATE0\r");
delay_ms(100);
do{
delay_ms(3000);
replies = "";
printf("AT\r");
get_string(replies,6);
if(strcmp(replies,rep_ok)==0){
CallReady = 1;
}
}while(CallReady==0);

CallReady = 0;
while(CallReady==0){
delay_ms(1000);
replies = "";
printf("AT+CREG?\r");
gets(replies);
if(strcmp(replies,rep_creg)){
CallReady = 1;
}

}
}​

I tried using gets() and get_string() functions, but in vein. Where am I at fault.

Please guys help me, I am in thick soup

Regards,
Spark
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…