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.

problem receiving response from gsm sim900

Status
Not open for further replies.

Pran Kumar

Newbie level 5
Joined
Jul 22, 2015
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
103
I am trying to send AT commands from PIC16f877a to sim900.I am trying to send each command ,then wait for the response and if response is received the response is cleared.Then the next command is sent.But i am facing problem when the response is cleared.The correct response is not being detected by the microcontroller.Please help me with the code.
Code:
[CODE]

char *p4;
#define MAXLEN 32
unsigned char buffer[MAXLEN],str[10] ;
volatile int Index1, CptErr,i1,full;
void send_AT();
void send_CSMINS() ;



void main()
{
INTCON.GIE = 1;
INTCON.PEIE = 1;
PIE1.RCIE = 1; //enable interrupt.
UART1_Init(9600);



send_AT(); //send at command
Delay_ms(1000);
memset(buffer, 0, sizeof(buffer)); //clear received response
send_CSMINS(); //send next at command


}



void interrupt()
{
unsigned char c1;
if (RCIF_bit)
{
if (RCSTA.OERR==1)
{
RCSTA.CREN = 0 ; // clear OERR flag
RCSTA.CREN = 1 ;
CptErr++;
c1=0; // empty buffer

}
else
if(RCSTA.FERR==1 )
{
CptErr++;
c1=0;
}
else
{
c1 = RCREG; // no errors
if (i1>31 ) //if maximum length of array exceeded
{
full=1;

i1=0; //next character stored as first element of array buffer[o]
buffer[i1]=c1;

i1++;

}
else
{
buffer[i1]=c1;
Index1=i1;

i1++;
}
}
}
}


void send_AT()
{
do
{
UART1_Write_Text("AT\r\n"); // send command string
Delay_ms(500);
p4 =strstr(buffer,"OK"); // check for response OK in buffer

}while(p4==0); // if null pointer received,OK not found, resend command
}

void send_CSMINS()
{
UART1_Write_Text("AT+CSMINS=1\r\n");

do
{ UART1_Write_Text("AT+CSMINS?\r\n"); Delay_ms(500); // send command string
p4 = strstr(buffer,"+CSMINS:1,1");
} while(p4==0);

}




Code:
[/CODE]
 

Zip and post uour complete mikroC PRO PIC project files. I will modify it.
 

i have attatched the compressed file of project file.Thank you.
 

Attachments

  • mikro.rar
    732 bytes · Views: 101

I asked you to zip and post the complete mikroC project files and not just the .c file. I have to see the project settings. Your UART buffer is small. The AT+CMGR header will need 80 to 90 bytes.
 

The attatched folder contains entire project files.
 

Attachments

  • edaboard.rar
    24.8 KB · Views: 94

Give an example of the SMS that you will send to SIM900. I need this to write the code. Are you trying to control some devices based on the received SMS ?
 

I am trying to control a motor using sim900 and dtmf decoder.
 

Explain how your system works in detail. For receiving SMS you need a buffer of atleast 120 bytes and when you use PIC16F with mikroC PRO PIC then mikroC doesn't generate memory bank switching code and it always give the warning that "IRP_bit must be set manually to access the variable xyz". So, even if you use a buffer of size 120 I am not sure it will work, but this problem doesn't occur when using PIC18F with mikroC PRO. So, Is it possible for you to change the device to PIC18F26K22 or some other PIC which has atleast 500 bytes RAM ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top