1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

Interfacing GSM module with microcontroller PIC18F452

Discussion in 'GSM' started by vimj, Jan 5, 2012.

  1. vimj

    vimj New Member

    Likes Received:
    0
    Trophy Points:
    0
    I understand that this forum is for 8051 microcontroller issues. However, 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. However, it doesn't work when it is interfaced with GSM modem. That is, I do not get OK for AT.

    If you do not have knowledge about PIC18F452, Can you at least mention the algorithm in general to interface a microcontroller with GSM Modem.

    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    ; 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: 25 for BRGH=1 FOR 4 MHZ crystal.
    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' ; Sending 'A' to GSM Modem and LCD
    RCALL TRANSMIT
    RCALL DATA1
    RCALL DELAY


    MOVLW 'T' ; Sending 'T' to GSM Modem and LCD
    RCALL TRANSMIT
    RCALL DATA1
    RCALL DELAY


    MOVLW 0X0D ; ASCII for Carriage Return
    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
  2. alex disuja

    alex disuja New Member

    Likes Received:
    0
    Trophy Points:
    1
Loading...
: pic18, gsm

Share This Page