This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Pls Help me to send AT cmds to GSM modem frm 8051

I m able to send the msg from hyperterminal with following commands.

AT
AT+CMGF=1
AT+CMGS=+91..MOBILE NO
SMS TEXT
ctrl+z

and when i wrote the following c-code to send the same text msg using 8051 serial port i m not able to send the text. code is as below;

#include <REG52.H>
void Send(unsigned char);
void MSDelay (unsigned int);
unsigned int i;
unsigned char msg1[]="AT";
unsigned char msg2[]="AT+CMGF=1";
unsigned char msg3[]="AT+CMGS=+91..mobile no";
unsigned char msg4[]="TEMPERATURE";

void main()
{

//*************serial communication initialization**********// P1 = 0x00; //Set port 1 as output TMOD = 0x20; //timer 1,mode 2(auto-reload) TH1 = -3; //9600 baud rate SCON = 0x50; //8-bit,1 stop, REN enabled TR1 = 1; //start timer 1

for(i=0;msg1[i]!='\0';i++) Send(msg1[i]); Send(0x0D); Send(0x0A); MSDelay(100);

for(i=0;msg2[i]!='\0';i++) Send(msg2[i]); Send(0x0D); Send(0x0A); MSDelay(100);

for(i=0;msg3[i]!='\0';i++) Send(msg3[i]); Send(0x0D); Send(0x0A); MSDelay(100);

for(i=0;msg4[i]!='\0';i++) Send(msg4[i]); Send(0x1A); while(1);
}

void Send(unsigned char x)
{ SBUF = x; while (TI==0); TI=0;
} void MSDelay (unsigned int value)// Delay routine { unsigned int x,y; for (x=0;x<3500;x++) for (y=0;y<value;y++);

}

------------------------------------------------------
i Have my project submission in 5 days.. pls pls help me out!!!!! Thanks in adwance...

Parents
  • If the AT standard intended delays to be used, then the documentation for the command would contain information about minimum delays required,

    But no, the command is not designed for use with fixed delays. It is designed for use in two-way mode, where your side catches any output from the modem, and adjusts your actions based on the responses.

    This forum, and the web in general, is peppered with discussions and suggestions and sample code.

Reply
  • If the AT standard intended delays to be used, then the documentation for the command would contain information about minimum delays required,

    But no, the command is not designed for use with fixed delays. It is designed for use in two-way mode, where your side catches any output from the modem, and adjusts your actions based on the responses.

    This forum, and the web in general, is peppered with discussions and suggestions and sample code.

Children
No data