EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / GSM sim900D interfacing with PIC18f548 problem in receiving message

GSM sim900D interfacing with PIC18f548 problem in receiving message

|

Microcontroller › PIC › GSM sim900D interfacing with PIC18f548 problem in receiving message

  • This topic has 0 replies, 1 voice, and was last updated 10 years, 1 month ago by Muhammad Ateeb Akmal.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • May 15, 2015 at 5:12 pm #3677
    Muhammad Ateeb Akmal
    Participant

    hi

    I am working on GSM 900D interfacing with PIC18f548. I am facing problem that I can get the message from the module. as I send at+cmgr=1;

    (1=location) i didnot get the message. while this is working properly with the computer as I send this comand by connecting GSM module with my PC. 

    I also can not get the OK message when I send AT through TX port. 

    here is my code. 

     

    #pragma config OSC = HS, OSCS = OFF
    #pragma config PWRT = OFF, BOR = ON, BORV = 27
    #pragma config WDT = OFF, LVP=OFF
    #pragma config DEBUG = OFF, STVR = OFF
    #include <P18F458.h>
    #include<stdio.h>
    #include <stdlib.h>
    #define ldata PORTD
    #define rs PORTBbits.RB0
    #define rw PORTBbits.RB1
    #define en PORTBbits.RB2
    #define busy PORTDbits.RD7
    void Delay(unsigned int DE);
    void LDelay(unsigned int DE);
    void lcdready(void);
    void lcdcmd(unsigned char);
    void lcddata(unsigned char);
    void lcd_int(void);
    void main(void)
    {
            unsigned char x,z,y,AT[]="ATr";
             unsigned char ATCMGF[]="AT+CMGF=1";
             unsigned char ATCMGR[]="AT+CMGR=1r";
             unsigned char ATCMGL[]="AT+CMGL="ALL"";
             unsigned char ATCMGD[]="AT+CMGD=1r";
             unsigned char ATD[]="ATD+923038310147;";
             unsigned char ATH[]="ATHr";
             unsigned char recno;
             unsigned char rec[40];
     
     
              TXSTA=0x20;
             RCSTA=0x90;
             SPBRG=19;
             TRISD=0;
            TRISB=0;
     
            RCSTAbits.SPEN=1;
            TXSTAbits.TXEN=1;
             RCSTAbits.CREN=1;
             PIE1bits.RCIE=1;    //Enable Reception interrupt
               lcd_int();
            lcddata('1');
             LDelay(60);
              for(z=0;z<4;z++)
              {
                while(PIR1bits.TXIF==0);
                TXREG=AT[z];
              }
                LDelay(5);
              while(PIR1bits.RCIF==0);
              rec[0]=RCREG;
     
              while(PIR1bits.RCIF==0);
              rec[1]=RCREG;
              lcd_int();
             for(y=0;y<=2;y++)
             {
                 lcddata(rec[y]);
             }
     
     
             LDelay(18);
            lcd_int();
            lcddata('2');
              for(z=0;z<9;z++)
              {
                while(PIR1bits.TXIF==0);
                TXREG=ATCMGF[z];
              }
                while(PIR1bits.TXIF==0);
                TXREG=0X0D;
                LDelay(20);
               lcd_int();
            lcddata('3');
             for(z=0;z<17;z++)
              {
                while(PIR1bits.TXIF==0);
                TXREG=ATD[z];
              }
             while(PIR1bits.TXIF==0);
                TXREG=0X0D;
             LDelay(110);
     
                 for(z=0;z<5;z++)
              {
                while(PIR1bits.TXIF==0);
                TXREG=ATH[z];
              }
             LDelay(30);
            lcd_int();
            lcddata('5');
              for(z=0;z<13;z++)
              {
                while(PIR1bits.TXIF==0);
                TXREG=ATCMGL[z];
              }
             while(PIR1bits.TXIF==0);
                TXREG=0X0D;
             LDelay(40);
            lcd_int();
            lcddata('6');
              for(z=0;z<11;z++)
              {
                while(PIR1bits.TXIF==0);
                TXREG=ATCMGR[z];
              }
     
             LDelay(40);
     
             lcd_int();
            lcddata('7');
     
            for(x=0;x<=40;x++)
            {
                while(PIR1bits.RCIF==0);
                rec[x]=RCREG;
            }
     
     
             lcd_int();
             for(y=0;y<x;y++)
             {
                if(y==15)
                lcdcmd(0xC0);
                 lcddata(rec[y]);
     
             }
             LDelay(20);
             lcd_int();
            lcddata('8');
            for(z=0;z<11;z++)
              {
                while(PIR1bits.TXIF==0);
                TXREG=ATCMGD[z];
              }
    //         while(PIR1bits.TXIF==0);
    //            TXREG=0X0D;
             LDelay(20);
             while(1);
    }
     
     
    void lcdcmd(unsigned char value)
      {
        ldata = value;
        rs = 0;
        rw = 0;
        en = 1;
        Delay(1);
        en = 0;
      }
    void lcddata(unsigned char value)
      {
        ldata = value;
        rs = 1;
        rw = 0;
        en = 1;
        Delay(1);
        en = 0;
      }
     
    void lcdready()
      {
        TRISD = 0xFF;
        rs = 0;
        rw = 1;
        do
         {
           en = 1;
           Delay(1);
           en = 0;
         }while(busy==1);
    TRISD = 0;
       }
    void Delay(unsigned int itime)
      {
        unsigned int i, j;
        for(i=0;i<itime;i++)
          for(j=0;j<135;j++);
    }
    void LDelay(unsigned int itime)
      {
        unsigned int i, j,k;
        for(i=0;i<itime;i++)
          for(j=0;j<255;j++)
          for(k=0;k<255;k++);
    }
    void lcd_int(void)
    {
     
            Delay(50);
            en = 0;
            Delay(250);
            lcdcmd(0x38);
            Delay(250);
            lcdcmd(0x0E);
            lcdready();
            lcdcmd(0x01);
            lcdready();
            lcdcmd(0x06);
            lcdready();
            lcdcmd(0x80);
    }
  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • PIC KIT 3 not able to program dsPIC June 19, 2025
  • Back to the old BASIC days June 19, 2025
  • using a RTC in SF basic June 19, 2025
  • what's it's name June 19, 2025
  • What is correct names for GOOD user friendly circuit drawing program? June 18, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise