Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GSM Module interfacing with Microcntroller

Status
Not open for further replies.

imtisal

Junior Member level 1
Junior Member level 1
Joined
Nov 12, 2012
Messages
18
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Visit site
Activity points
1,418
Hi everyone
I know that this topic has been discussed earlier but i've one confusion regarding sending and receiving message thats why i've created a separate topic for that.

I know all the AT commands and i know serial communication too. i've communicated GMS module with hyperterminal and its working correctly but the main problem is im unable to do this through micronctroller(AT 89C51) :( and im unable to understand the problem behind that. So kindly help me on that.
I've tried AT commands on hyperterminal and all are working fine. and I've checked my microcontroller circuit too and its also fine. But still when i burn the code in microcontroller, its not working at all :(
Im using SIM 900 module for interfacing
I've used a small code that when i send a message to a number that i've used in coding it has to reply me back after receiving it. but it never happens.
 

I've tried AT commands on hyperterminal and all are working fine. and I've checked my microcontroller circuit too and its also fine. But still when i burn the code in microcontroller, its not working at all
When you send data from MCU tx pin, do you see data coming to gsm rx pin?

Is the initialize sequence OK? Are you handling the PWRKEY pin correctly after power on as described in datasheet? You can find all documentation on SIM900 inside SIMCom's web page.
**broken link removed**
 

Hi to all,
Sorry for late reply,
here is the code of my project, kindly help me out,
Code:
#include<AT89X51.H>
void tx(unsigned char);
void delay_ms(unsigned int);
void serial_ini();
void gsm_ini();
char rx();
void reply();
unsigned char AT[]="AT";
unsigned char CMGF[]="AT+CMGF=1";
unsigned char CMGS[]="AT+CMGS=+923348221338";
unsigned char msg[]="Hello,";
unsigned char msg2[]="A has been received";
char ctrlz=0x1A;
char enter=0x0D;
int k,m,j;
char rec_data;

void main()
{
 
        while(1)
{
  serial_ini();
        gsm_ini();
        rec_data=rx();
        if(rec_data=='A')
        {
                reply();
                }
                j=0;
        }

}
void delay_ms(unsigned int x)
{
int i,j;
for (i=0;i<x;i++)
for(j=0;j<1275;j++); 
}
void tx(unsigned char x)
{
SBUF=x;
TI=0;
while(TI==0);
TI=0;
}

char rx()
{
        while(RI==0);
        return SBUF;
        RI=0;
}

void serial_ini()
{
TMOD=0x20;
SCON=0x50;
TH1=0xFD;
TL1=0xFD;
TR1=1;
}
void gsm_ini()
{

while(AT[k]!='\0')
{
tx(AT[k]);
delay_ms(10);
k++;
}
k=0;

tx(enter);

while(CMGF[k]!='\0')
{
delay_ms(10);
tx(CMGF[k]);
k++;
}
k=0;

tx(enter);

  while(CMGS[k]!='\0')
{
delay_ms(10);
    tx(CMGS[k]);
k++;
  }
k=0;

tx(enter);

while(msg[k]!='\0')
{
delay_ms(10);
tx(msg[k]);
k++;
}
k=0;
tx(ctrlz);
}



void reply()
{
  while(CMGS[k]!='\0')
{
    delay_ms(10);
    tx(CMGS[k]);
k++;
  }
k=0;
tx(enter);        

while(msg2[k]!='\0')
{
delay_ms(10);
tx(msg2[k]);
k++;
}
k=0;
tx(enter);
tx(ctrlz);                 // Trasnmit message
}

- - - Updated - - -

It showing no error while compilation, but also give no response when I check it on hardware,

@Alexxx , Yes , initialization sequence is OK,

I am stucked in this code, kindly help me out,
 

I don't see modem's PWRKEY input to be manipulated as described in datasheet, before even sending any data. When you are communicating with the PC is it with the same board? If yes, then during communication with the PC you keep MCU's reset pin grounded? How do you manage that, PC and MCU on the same board? Did you check data with oscilloscope?

Finally all initializations running inside main loop. They should run before. Something like:

Code:
serial_ini();
gsm_ini();

while(1)
{
  //place code for communication with gsm here
}
 

what is a PWRkey? in order to transmit and receive data, i have to push it manually.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top