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

not getting messages from gsm modem

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

Parents Reply Children
  • every one who post a thread wants to fix their problems.even i wanted to fix my problem.for that i needed to know where my mistake was.thats what i mentioned in thread 'point out the mistake in the code'. if you want somebody to rewrite your code, hire a consultant whats wrong with you ? i never mentioned anything like that in my thread.

  • 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?

  • In the previous thread, there were a number of notes about things to think about with your code. It wasn't a complete list, but it should have gotten you started.

    Problem is: you started a new thread but didn't start working through the points you received. As you have to be aware, there is still not any code for real two-way duplex communication with the modem.

    And when you got a comment about a delay - did you then start to look closer into the needs for delays, and what options exists for real delays that actually performs a timed delay?

    In the end, the modem will continue to be a two-way device even if you are getting grumpy about receiving comments about the need to handle characters in both directions - and not always at a time you like.