i am using atmel at89s52 and a sim 300 gsm modem.i just want to sent a message to my cell phone.i am new to microcontroller programming.here is my code-
#include<reg51.h> void serialcomm() { TMOD=0x20; // Mode=2 TH1=0xfd; // 9600 baud SCON=0x50; // Serial mode=1 ,8-Bit data,1 Stop bit ,1 Start bit , Receiving on TR1=1; // Start timer } void delay(unsigned int value) { unsigned int i,j; for(i=0;i<value;i++) for(j=0;j<1275;j++); } void serial(unsigned char x) { SBUF=x; while(TI==0); TI=0; } void Send2Gsm(char *aaa) { unsigned int i; for(i=0;aaa[i]!=0;i++) { serial(aaa[i]); } } void main() { serialcomm(); Send2Gsm("AT\r\n"); delay(2); Send2Gsm("AT+CMGF=1\r\n"); delay(2); Send2Gsm("AT+CMGS=\"+918762357075;\"\r\n"); delay(2); Send2Gsm("hy"); serial(0x1a); while(1); }
the code looks fine to me,and i did as per the procedure.but,when i tried it in my circuit,i am not getting any messages.gsm works fine and i tested it in hyperterminal.any mistakes in code ?? please help
The communications with the modem are a two way affair, you can't just throw in arbitrary delays and pray.
What responses do you get from the modem now?
Can you read out the IMEI number, SIM number and confirm that the modem is actually registered on to a wireless network?