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 / Interfacing SIM300 GSM Modem with PIC18F452

Interfacing SIM300 GSM Modem with PIC18F452

|

Microcontroller › PIC › Interfacing SIM300 GSM Modem with PIC18F452

  • This topic has 0 replies, 1 voice, and was last updated 13 years, 5 months ago by Vimarsh Jani.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • January 5, 2012 at 10:43 am #1762
    Vimarsh Jani
    Participant

     

    I would be really grateful if someone has knowledge about PIC18F452 and would help me with its interfacing with GSM modem. The following program works successfully when interfaced with HyperTerminal. That is, PIC18 sends AT and I manually send OK and PIC displays it on LCD Screen. However, it doesn’t work when it is interfaced with GSM modem. That is, I do not get OK for AT when PIC is interfaced with GSM modem.

    Also, Can you mention the algorithm for interfacing PIC to GSM modem?

     

    Thank you!

     

     

    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    ; Program to test interfacing of PIC18F452 with GSM Module.

    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

     

                                                                    listp=18f452                                        ; Using PIC18F452

                                                                    #include<p18f452.inc>

                                                   

                                                                    REG1 EQU 0X000

                                                                    REG2 EQU 0X001

     

                                                                    ORG 0X0000

    EUSART:                                               BSF INTCON, GIE                                              ; Enable global interrupts

                                                                    BSF INTCON, PEIE                            ; Enable peripheral interrupts

     

                                                                    MOVLW B’00100100′                       ; Enable transmit, 8 bits, HIGH-speed baud, asynchronous mode

                                                                    MOVWF TXSTA

                                                                    MOVLW D’25’                                                    ; Byte for 9600 baud 5.5104 FOR 4 MHZ, 15 FOR 10 MHZ CRYSTAL, 25 for BRGH=1 FOR 4 MHZ

                                                                    MOVWF SPBRG

                                                                    MOVLW B’10010000′                       ; Enable serial port, 8 bits, receive enable, No Check for framing or overrun error

                                                                    MOVWF RCSTA

                                                                   

    USARTINT:                         

                                                                    BSF PIE1, TXIE                                    ; Enable interrupt for transmitting data

                                                                    BSF PIE1, RCIE                                    ; Enable interrupt for receiving data

     

                                                                    clrf TRISC

                                                                    BSF TRISC, RX                                    

                                                                    clrf TRISD

                                                                    CLRF TRISB

     

                                                                    MOVLW 0X38                                                    ; Initialising LCD with 2 lines 5 x 7 matrix   

                                                                    RCALL CMD

                                                                    RCALL DELAY

                                   

                                                                    MOVLW 0X0E                                                    ; Display on, cursor blinking

                                                                    RCALL CMD

                                                                    RCALL DELAY

                                   

                                                                    MOVLW 0X01                                                    ; Clear display screen

                                                                    RCALL CMD

                                                                    RCALL DELAY

                                   

                                                                    MOVLW 0X06                                                    ; Increment cursor (shift cursor to the right)

                                                                    RCALL CMD

                                                                    RCALL DELAY

                                   

                                                                    MOVLW 0X80                                                    ; Force cursor to beginning of 1st line.

                                                                    RCALL CMD

                                                                    RCALL DELAY

                                                                   

                                                                    MOVLW ‘A’

                                                                    RCALL TRANSMIT

                                                                    RCALL DATA1

                                                                    RCALL DELAY

     

                                                                    MOVLW ‘T’

                                                                    RCALL TRANSMIT

                                                                    RCALL DATA1

                                                                    RCALL DELAY

     

                                                                    MOVLW 0X0D                                                      ; ASCII for Carriage Return

                                                                    RCALL TRANSMIT

     

                                                                    MOVLW 0X0A                                                      ; ASCII for New Line

                                                                    RCALL TRANSMIT

                                                   

    AGAIN:                                 RCALL RECEIVE                                  ; Receiving information from GSM Modem and displaying it on LCD

                                                                    RCALL DATA1

                                                                    RCALL DELAY

     

                                                                    BRA AGAIN

     

     

    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    ; SUBROUTINES

    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

     

    TRANSMIT:                         BTFSS PIR1, TXIF                               ; Check if transmit register is empty

                                                                    BRA TRANSMIT                                 ; If not, wait until it is empty

                                                                    MOVWF TXREG                                                                ; Write byte from W register into TXREG.

                                                   

                                                                    RETURN

     

    RECEIVE:                              BTFSS PIR1, RCIF                               ; Check if new data byte arrived in RCREG

                                                                    GOTO RECEIVE                                  ; If RCIF flag is not set, go back and wait

                                                                    MOVF RCREG, W                                              ; If a new data byte has arrived, save in W register

     

                                                                    RETURN

     

    CMD:                                     MOVWF PORTD,0                                            ; Send command on PORT D

                                                                    BCF PORTC, 0, 0                                                ; (Port C pin no. 0) RS = 0 i.e. instruction command code register is selected

                                                                    BCF PORTC, 1, 0                                                ; (PC pin 1) R/W-b = 0 i.e. Writing operation

                                                                    BSF PORTC,2,0                                   ; (PC pin 2) E = 1

                                                                    BCF PORTC,2,0                                  ; E = 0 i.e. a high to low transition for LCD to latch in the data present at data pins

                                                                    RETURN 0

     

    DATA1:                                 MOVWF PORTD,0                                            ; Send data on PORT D

                                                                    BSF PORTC, 0, 0                                 ; RS = 1 i.e. data register is selected

                                                                    BCF PORTC, 1, 0                                                ; R/W-b = 0 i.e. Writing operation

                                                                    BSF PORTC,2,0                                   ; E = 1

                                                                    BCF PORTC,2,0                                  ; E = 0 i.e. a high to low transition for LCD to latch in the data present at data pins

                                                                    RETURN 0

     

    DELAY:                                 MOVLW D’255′                                  ; Delay subroutine.

                                                                    MOVWF 0X20,0

    UP:                                                         DECF 0X20,1,0

                                                                    BNZ UP

                                                                    RETURN 0

     

                                                                    END

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

RSS Recent Posts

  • Fun with AI and swordfish basic June 22, 2025
  • Microinverters and storeage batteries? June 22, 2025
  • FFC connector white June 22, 2025
  • Is AI making embedded software developers more productive? June 22, 2025
  • Can I make two inputs from one?? June 22, 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