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.

Interfacing SIM300 GSM module with microcontroller PIC18F452

Status
Not open for further replies.

vimj

Newbie level 2
Joined
Jan 5, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,321
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 PIC18F452 is interfaced with HyperTerminal. That is, PIC sends AT to HyperTerminal and I manually send OK to PIC and it displays the same on LCD screen. However, it doesn't work when it is interfaced with GSM modem. That is, I do not get OK for AT.

Also, can you at least mention the algorithm in general to interface a microcontroller with GSM Modem. I am using SIM300 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 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
 

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 PIC18F452 is interfaced with HyperTerminal. That is, PIC sends AT to HyperTerminal and I manually send OK to PIC and it displays the same on LCD screen. However, it doesn't work when it is interfaced with GSM modem. That is, I do not get OK for AT.

Also, can you at least mention the algorithm in general to interface a microcontroller with GSM Modem. I am using SIM300 GSM Modem

From hyperterminal what you are sending to PIC for AT Response? Is it OK and Enter(ASCII 13)? or OK with ASCII 10 and 13?

I think you are sending OK and 13, thats why it is working with Hyoerterminal,

Understand SIM300 AT command first. First of all you need to disable Echo by ATE0 command, than program your PIC to receive response ending with 10 and 13 ASCII. and test that on Hyper Terminal and than with SIM300.

Hope this may help you
 
Thank you for your reply. I will try your suggestions.

As far as your question about hyperterminal is concerned, With the code above, I have programmed PIC to transmit AT, ASCII 13 AND ASCII 10 to hyperterminal and then wait for characters. Then as I type O, it is received and displayed on LCD. And followed by O, as I type K, it is received and displayed on LCD screen. So basically, whatever is typed and received is simply displayed on the LCD screen.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top