Skip to main content
1 of 2
S Andrew
  • 621
  • 12
  • 29

Unable to receive response from SIM900

I am trying to communicate to SIM900 with PIC18F2520. I am able to send AT commands using UART but I also want to receive its response like OK or ERROR.

Following is the code for RX interrupt

#pragma code rx_interrupt = 0x8
void rx_int(void)
{
  _asm goto rx_handler _endasm
}
#pragma code
#pragma interrupt rx_handler
void rx_handler(void)
{
  while (!DataRdyUSART());   //if data is ready to receive
  for(k=0;k<=20;k++)
  {
        
    Rx[k] = getcUSART();    //read a byte from UART
    
  }
  UARTSend("We have read everything");   //I have a put a breakpoint here
  if(strstr(Rx,"OK") != NULL)
  {
    UARTSend("OK received"\n);
  }
   
   PIR1bits.RCIF = 0;   //Clear the interrupt flag 

}

Above is the code I am using for receiving data from SIM900. In the debug mode, I send UARTSend("AT\r");. I have a put a breakpoint at UARTSend("We have read everything");. At this line, I check for the Rx buffer in variable but it doesnt have OK instead it has few random chars while on the terminal I am getting proper response.

enter image description here

So how to read response from SIM900. The approach I am using it correct or not.Please help.

S Andrew
  • 621
  • 12
  • 29