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.

[PIC] mikroC code for recieving sms from sim900 module and show on lcd

Status
Not open for further replies.

amirhomayoon

Newbie level 2
Joined
Oct 25, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
17
i want to receive a sms from my sim900 module and show it on lcd, pls give me a code for that , i use mikroc pro and pic16f877a this is very urgent and important for me pls help me , i can send sms but i cant receive
 
Last edited by a moderator:

hello,

i used this code on a GSM QUECTEL M95 not SIM900
but i think it is the same deal.

Suppose that you receive RX UART into a buffer ,trough interrupt treatment
and arm a flag when you encounter the car "LF" = 0x10
UART1 is used to diplay the dialogue with GSM (as a debugger)
UART2 is connected to the GSM

most important is the UART Receiving treatment ...

Code:
      if (UART2_DataReady==1)
            {
             p=strstr(buffer2,"CMTI");   // detect SMS arrival
              if (p>0)
              {
              LCD_RAZ_Ligne(1);
              LCD_Write_CText(1,1,"Reception SMS   ");
              UART1_Write_CText(" Read message NON LUS (AT+CMGL="REC UNREAD")\r\n");
              UART2_Write_CText("AT+CMGL="REC UNREAD"\r");
              Delay_ms(3500);
             // SMS displying on terminal 
              UART1_Write_Text(buffer2); 
              CRLF1();
... then you also  can display on LCD ...but divide the message modulo 16 car !
      }

UARTx interrupt treatment


Code:
void Interrupts() iv 0x0008 ics ICS_AUTO
{
//UART1
 
//UART2
   if((RC2IF_bit==1) && (RC2IE_bit==1))
    {
      if(OERR2_bit)
      {
         CREN2_bit = 0;
         CREN2_bit = 1;
      }
      if(FERR2_bit)
      {
        c2 = RCREG2;
        c2=0;
      }
      //c2 = UART2_Read();
      c2=RCREG2;
      if (c2==10)
      // terminaison par CR LF
      {
         UART2_DataReady=1;
        //interdit IT Reception UART
        // PIE2.RC2IE=0 ;
        buffer2[i2]=c2 ;
        Index2=i2;
        // i2=0;
         c2=0;
       }
        else
       {
          buffer2[i2]=c2;
          Index2=i2;
          i2++;
       }

       if (i2 >=MAXLEN2)
       {
          UART2_DataReady=2;
          // RCSTA2.CREN=0;
          RC2IE_bit=0 ;
          //interdit IT Reception UART
          i2--;
          buffer2[i2]=0;
          Index2=i2;
          i2=0;
          c2=0;
       }
     }

 // === interrupt RB0 ===
 
  //   ====  IT Timer0  ==
 

}
 

I think it is a bit diffrent
We dont have some of this functions , pls tell me what is lcd_raz_lign(1)
Also pls tell me what micro is this because i think pic16f877 dont have 2 uart
 

We dont have some of this functions , pls tell me what is lcd_raz_lign(1)

it is a own function wich erase all caracteres in line 1 of LCD , with blank car (space) and return
the cursor at the first position in the line ( line 1)
so ready to receive a new message

Also pls tell me what micro is this because i think pic16f877 dont have 2 uart
i am using 18F87J50 clicker2
but you can remove all code concerning UART1 .. because only used for debug purpose
and rename UART2 as UART .. UART existing in 16F877


SMS AT commands and response from GSM are quiete universal !
i dont' know detail about SIM9000
but you must have a header response (like "CTMI") when incomming SMS arrive ..

or you have a RING "RI" signal from SIM9000 ..
to check with an interupt pin like RB0 input, then read the SMS

- - - Updated - - -

Where did you find this word?

i am using a LCD 2119 2x16 c I2C mode
and i wrote my own functions.. it is not from LCD mikroC library

Code:
void LCD_RAZ_Ligne( int L)
{
 I2C1_Start();
 I2C1_Wr(LCD_ADR); // i2c slave Address
 I2C1_Wr(0x00); // Control byte for Instruction
 I2C1_Wr(0x02); // return home
 switch (L)
 {
  case 1:
      I2C1_Wr(0x80); // DDRAM Address 1ere ligne
      break;
  case 2:
      I2C1_Wr(0xC0); // DDRAM Address 2em ligne
      break;
  default:
  break ;
 }
 I2C1_Repeated_Start();
 I2C1_Wr(LCD_ADR); // i2c slave Adress
 I2C1_Wr(0x40);     // Control byte for Data
 for (i=0;i<39;i++)
 {
   I2C1_Wr(0x80+32); // efface avec des blanc
 }
 // repositionne au debut de ligne
 I2C1_Repeated_Start();
 I2C1_Wr(LCD_ADR); // i2c slave Adress
 I2C1_Wr(0x00); // Control byte for Instruction
 //I2C1_Wr(0x40);     // Control byte for Data
 switch (L)
  {
   case 1:
         I2C1_Wr(0x80); // DDRAM Address 1ere ligne
        break;
   case 2:
        I2C1_Wr(0xC0); // DDRAM Address 2em ligne
        break;
   default:
        break ;
  }
 I2C1_Stop();
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top