[SOLVED] problem on receiving message from GSM

Status
Not open for further replies.

PRABAKARDEVA

Full Member level 2
Joined
Sep 16, 2013
Messages
127
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Location
Chennai
Visit site
Activity points
2,168
Hi..

I am using PIC 16F877A Microcontroller and SIM 300 GSM Modem

Actually I can send sms using SIM 300, can receive the message location and displayed that on lcd.

Everything works on hyperterminal.
But in hardware i couldn't receive the message from the modem.I couldn't find the problem..
 

Attachments

  • gsm_receive.rar
    641 bytes · Views: 75

do you receive anything from the modem when you expect an sms text?
for example, could ou be loosing received character because you are not reading the UART sufficently fast?
what baud rate is the SIM 300 ? are you using polled or interrupt receive on the UART?
 

You can use an oscilloscope to test the waveform at RXD point,to make sure was there any data in.and then if there was,it must be errors in your program.
 

Hi I have also faced this problem during my project.
Basics steps to receive sms are:

1. Check the PIR1.RCIF regester.
2.Save Memory slot as:
Read:
+CMTI: , <MEMORY SLOT>
3: Use the command: AT+CMGR=
4. Enter memory slot you saved
5. Extract the whole message and save it to array.
6. Delete the message.

This is the code, not complete, gives you idea:


Code:
// Variables
volatile unsigned char i=0,j=0, yesgot=0, message[100];
volatile unsigned int storedloc=0,gotit;

// STEP.1-- CHECK REGISTER

unsigned char rx_incoming() 
 {                                 
 while(PIR1.RCIF==0); // if data not read stay here                     
 return RCREG;        // Data is present in this regester
 }                    // Return means take   

void main()
{
 
 
 delay_ms(40);

 UART1_Init(9600);

 RCSTA.SPEN=1;RCSTA.CREN=1;   // To set usart pins as Transmitter
 delay_ms(50);

 UART1_Write_Text("ATE0");    // Echo Off
 UART1_Write(0xd);
 delay_ms(40);
 UART1_Write_Text("AT+CMGF=1");
 UART1_Write(0xd);

 
 //STEP2. -----Save Memory Slot
 while(storedloc==0)
 {
 gotit= rx_incoming();
 if(gotit=='+')
 {
 gotit= rx_incoming();
 if(gotit=='C')
 { gotit=rx_incoming();
 if(gotit=='M')
 {
 gotit=rx_incoming();
 if(gotit=='T')
 {
 gotit=rx_incoming();
 if(gotit=='I')
 {
 gotit=rx_incoming();
 if(gotit==':')
 {
 gotit=rx_incoming();
 while(gotit!=',')gotit=rx_incoming();
 storedloc=rx_incoming();
 }
 }
 }
 }
 }
 }                     // Memory slot saved
 }

// STEP.3 ----- Use command                                      
 delay_ms(100);                     //
 UART1_Write_Text("AT+CMGR=");      // Read SMS   
 UART1_Write(storedloc);            //
 UART1_Write(0xd);


// STEP.4------Extracting SMS CMGR+ :
while(yesgot==0)
{
 gotit=rx_incoming();
 if(gotit=='+')
 {
 gotit=rx_incoming();
 if(gotit=='C')
 {
 gotit=rx_incoming();
 if(gotit=='M')
 {
 gotit=rx_incoming(); 
 if(gotit=='G')
 {
 gotit=rx_incoming();
 if(gotit=='R')
 {
 gotit=rx_incoming();
 if(gotit==':')
 {                              // Save in Array
 gotit=rx_incoming();

 while(gotit!=0xa){gotit=rx_incoming();}

//STEP.5---- save in array

 for(i=0;gotit!=0xd;i++){gotit=message[i]=rx_incoming();}

 UART1_Write_Text("AT+CMGD="); // Delete
 UART1_Write(storedloc);
 UART1_Write(0xd);
 Lcd_Out(1,1,message);                    // LCD Display
 yesgot=1;
 }
 }
 }
 }
 }
 }
 }

// Fahad Wasti
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…