kemystri
Junior Member level 2
- Joined
- Feb 13, 2008
- Messages
- 20
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,446
pic gsm
i had a problem poh
i made a module wherein it purpose is to communicate with GSM module
we tried the module using hyperterminal and it works properly
but when we try to connect it to gsm module, it seems that the command or ascii code that we were sending doesnt
recieve by the gsm module.
what was our problem?
is there a correct braud rate for the gsm module? accrding to the spec its auto baud rate
should we use the 9 bit?
whats wrong with our aproach?
whats with interrupt?
heres the our program
i had a problem poh
i made a module wherein it purpose is to communicate with GSM module
we tried the module using hyperterminal and it works properly
but when we try to connect it to gsm module, it seems that the command or ascii code that we were sending doesnt
recieve by the gsm module.
what was our problem?
is there a correct braud rate for the gsm module? accrding to the spec its auto baud rate
should we use the 9 bit?
whats wrong with our aproach?
whats with interrupt?
heres the our program
;*****************************************************************;
; REAL-TIME GROUP ;
; Test Program for USART ;
; Date Created: January 17, 2008 4:00 PM ;
; ver 1.0 ;
;*****************************************************************;
list p=16F877; list directive to define processor
#include <p16F877.inc>; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC & _BODEN_OFF & _LVP_OFF
DataByte equ 20h
TEMP2 equ 21h
DELA1 equ 22h
DELA2 equ 23h
DELA3 equ 24h
TEMP_PORTA equ 25h
loop_delay_char equ 26h
org 00h
;************************************
; Set Up the Baud Rate of the
; USART to 9600 bps
;************************************
BANKSEL SPBRG
movlw d'25'
movwf SPBRG
BANKSEL TXSTA
bsf TXSTA,BRGH
;************************************
; Set Up the The Reception of Data
; Continuous Reception is enabled
;************************************
BANKSEL TXSTA
movlw B'00100100'
movwf TXSTA
BANKSEL RCSTA
movlw B'10010000'
movwf RCSTA
bcf status,rp0
bcf status,rp1
BANKSEL TRISB
bcf trisb,7
bcf trisb,5
bcf trisb,3
BANKSEL TRISA
bsf TRISA,3
bcf TRISA,0
bcf TRISA,1
bcf TRISA,2
movlw d'6'
movwf ADCON1
BANKSEL PORTA
bcf PORTA,0
bcf PORTA,1
bcf PORTA,2
START
banksel PORTb
bcf portb,3
BANKSEL PORTA
movf PORTA,w
movwf TEMP_PORTA
bsf TEMP_PORTA,0
bsf TEMP_PORTA,1
bsf TEMP_PORTA,2
movf TEMP_PORTA,w
BANKSEL PORTA
movwf PORTA
call delay
btfss TEMP_PORTA,3
goto START
bcf TEMP_PORTA,0
bcf TEMP_PORTA,1
bcf TEMP_PORTA,2
movf TEMP_PORTA,w
BANKSEL PORTA
movwf PORTA
;==================================
;change hexadecimal to text mode
;==================================
call delay
call delay
call delay
banksel PORTb
bsf portb,3
movlw h'61'
call sub_sendByteToPhone
call loop_tx
movlw h'74'
call sub_sendByteToPhone
call loop_tx
;================================
;test if ok?
;we checked if we recieve a "ok" reply from the gsm
;================================
SEND_O2
call loop
movf DataByte,w
addlw -a'O'
btfss STATUS,Z
GOTO SEND_O2
banksel pir1
bcf PIR1, RCIF ;clear the character present flag
banksel PORTb
bsf portb,7
SEND_K2
CALL LOOP
movf DataByte,w
addlw -a'K'
btfss STATUS,Z
GOTO SEND_K2
banksel pir1
bcf PIR1, RCIF ;clear the character present flag
banksel PORTb
bcf portb,7
bsf portb,5
goto start
sub_sendByteToPhone
BANKSEL TXREG
movwf TXREG
return
;========================
;normal delay
;========================
delay
movlw d'1'
movwf dela3
loop3
movlw d'20'
movwf dela2
loop2
movlw d'20'
movwf dela1
loop1
nop
nop
nop
decfsz dela1,f
goto loop1
decfsz dela2,f
goto loop2
decfsz dela3,f
goto loop3
return
;========================
;delay for enter
;========================
;========================
;delay for chracters
;========================
delay_char
movlw d'1'
movwf dela3
loop3_char
movlw d'20'
movwf dela2
loop2_char
movlw d'20'
movwf dela1
loop1_char
nop
nop
nop
decfsz dela1,f
goto loop1_char
decfsz dela2,f
goto loop2_char
decfsz dela3,f
goto loop3_char
decfsz loop_delay_char,f
call delay_char
return
var_char
movlw d'5'
movwf loop_delay_char
return
Loop
BANKSEL PIR1
btfss PIR1, RCIF ;wait for receive character set
goto Loop ;nothing there
readByteFromPhone
;put data received from RCREG
;to W register and DataByte register
BANKSEL RCREG
movf RCREG,W
BANKSEL DataByte
movwf DataByte
return
Loop_tx
BANKSEL PIR1
btfss PIR1,TXIF
goto Loop_tx
return
end