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
  • Stripping away the sensor code will not make the rest of the code any better.

    It still doesn't care about any responses from the modem. It still has a delay function of unkonwn length. It still thinks "aaa" is a descriptive variable name. It still ...

    Isn't it time to start spending some actual work on this code instead of taking a cursory glance at it and consider "the code looks fine"?

  • i posted my first thread about my main project,and i found that the whole code is wrong.so,i thought i will start from the basic .that is the reason why i started my second thread about 'sending a message through a gsm modem',and i didnt find any mistakes in that.(i may be wrong as i said i am new to programming).
    so,instead of correcting the mistakes in my code and helping me,you guys are finding mistakes in me and discouraging me.so,why don't you do that ? i never expected these kinds of reply. 'Stripping away the sensor code will not make the rest of the code any better' seriously ? i thought i will divide the mistakes in my code , and start repairing individually. i spend a lot of time to learn about GSM in internet, and i got only few information. this is my final year project ,and that is the reason why i posted a thread so that i will get a guidance in programming.
    please tell me how to get guidance.

  • instead of correcting the mistakes in my code and helping me

    in your original thread

    http://www.keil.com/forum/57777/

    the second post list what YOU need to fix, if you want somebody to rewrite your code, hire a consultant.

    posting some defective code downloaded from the internet with "FIX IT" is not what 'coding' compromises.

    the purpose of a forum like this is to help YOU fix your problems, NOT fix them for you.

    Erik

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