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 interfacing with PIC18F4550

GSM interfacing with PIC18F4550

|

Microcontroller › PIC › GSM interfacing with PIC18F4550

  • This topic has 2 replies, 3 voices, and was last updated 12 years, 1 month ago by Nidhin.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 25, 2013 at 5:52 am #2086
    Alamgir
    Participant

    I am using PIC18F4550 for interfacing with GSM SIM 900. i have cheked it via hyperterminal at baud rate of  9600 and the gsm work perfectly, but when now at the controller it dosn’t give the expected results. The c code written in mp lab is given. please help me with this, why isn’t it working.

     

    #include<p18f4550.h>
    #include<delays.h>

    # pragma config WDT=OFF
    # pragma config LVP=OFF
    # pragma config FOSC=HS
    # pragma config IESO=OFF
    # pragma config MCLRE=ON
    # pragma config PBADEN=OFF

    unsigned char value=0;
    int i=0, k=0,j=0;

    unsigned char *at_cmd=”AT”;
    unsigned char *sms_format=”AT+CMGF=1″;
    unsigned char *sms_write=”AT+CMGS=”03006464297″”;
    unsigned char *sms=”Hello”;
    unsigned char enter=0x0D;
    unsigned char *data;

    #define FREQ 11059200
    #define baud 9600
    #define spbrg_value (((FREQ/64)/baud)-1)
    unsigned char rx_data(void);

    void tx_data(unsigned char serial_data)    ;
    void gsm_cmd(unsigned char *);
    int check(unsigned char *);

    void main()
    {

        TRISB=0;
        LATB=0;
       
     
        TRISC=0xC0;
       
     

       
        
        
        //BAUDCONbits.WUE=1;

        TXSTAbits.SYNC=0;
        BAUDCONbits.BRG16=0;
        SPBRG=spbrg_value;            // Fill SPBRG register to set the baud rate

        
        INTCONbits.GIE=1;                // Enable Global interrupt
        INTCONbits.PEIE=1;                // Enable Peripheral interrupt
        
        

         RCSTAbits.SPEN=1;                // To activate serial port (Tx and Rx pins)
        PIE1bits.RCIE=1;                // Enable Reception interrupt
        RCSTAbits.RX9=0;

        RCSTAbits.CREN=1;                // Activate Reception
        

       
        PIE1bits.TXIE=1;
        PIE1bits.RCIE=1;
        TXSTAbits.TX9=0;
        TXSTAbits.TXEN=1;                // Activate Transmissiom
        RCSTAbits.RX9=1;
                         

    while (1)
    {
            {
    PORTBbits.RB0=1;
                gsm_cmd(at_cmd);
                Delay10TCYx(500);
               i=0;
    while(i<2)
    {
    data=rx_data();
    i++;
    }            
    if (check(data))
          {  
            PORTBbits.RB1=1;
               
                gsm_cmd(sms_format);
                Delay10TCYx(500);
              i=0;
    while(i<2)
    {
    data
    =rx_data();
    i++;
    }           
    if (check(data))
    {
          PORTBbits.RB2=1;
          gsm_cmd(sms_write);
                Delay10TCYx(500);
            

    PORTBbits.RB3=1;            
     gsm_cmd(sms);
                 
                tx_data(0x1A);
                Delay10TCYx(500);

    }
    }
    }
    }
    }

    unsigned char rx_data(void)
    {
        while(PIR1bits.RCIF==0);                            // Wait until RCIF gets low
        return RCREG;                                   // Retrieve data from reception register
    }

    void tx_data(unsigned char serial_data)        // Transmit data function
    {
        TXREG=serial_data;
        while(PIR1bits.TXIF==0);
    }

    void gsm_cmd(unsigned char *string)
    {
    i=0,j=0;
        while(string
    !=’’)
        {
            tx_data(string
    );    
            i++;
        }
        tx_data(enter);    
    }

    int check(unsigned char *string)
    {
    int i=0;
    if(string
    ==’O’)
    {
    i++;
    if(string
    ==’K’)
    {return 1;
    }
    else
    return 0;
    }
    else
    return 0;

    }

    January 25, 2013 at 9:35 am #9050
    AJISH ALFRED
    Participant

    Hi Alamgir,

    Connect your controller to the hyperterminal and make the code running. Obsere whether your controller generates the same commands there.

    April 10, 2013 at 5:42 pm #9453
    Nidhin
    Participant

    Hi…

              

             I build this program. it is succesfully build in my mplab c complier.   I dont know what are the issues u facing. can you upload the circuit diagram of this project.??

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • LED circuit for 1/6 scale diorama May 15, 2025
  • stud mount Schottky diodes May 14, 2025
  • using a RTC in SF basic May 14, 2025
  • Hi Guys May 14, 2025
  • Can I use this charger in every country? May 14, 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