justrain
Joined: 12 Nov 2008 Posts: 3
|
Connecting a PIC with an Ezurio Bluetooth module help |
Posted: Wed Nov 12, 2008 4:01 pm |
|
|
Hi, i'm trying to connect a PIC18F4680 module to a Bluetooth BISM from Ezurio (BISMS02BI) which uses the AT command language for configuration. I'm connecting both parts with an RS232 connection but the problem is that whenever I send a comand i.e ATZ followed by the 0x0D I get no response from the Bluetooth module, i've connected the PIC to a PC terminal and checked that the commands were sent right, but when I replace the PC with the bluetooth I get nothing.
Does anyone have some idea what this is happening? bellow is the code I'm using which is on assembly...
Code: |
org 0x860
msjez: DB "ATZ."
org 0x880
msje: DB "ATE0."
org 0x900
msjep: DB "AT+BTW111111111111."
;msje_2:DB "AT+BTK='0000'."
org 0x990
Main:
;Serial PORT Config
movlw 0x24
movwf TXSTA
movlw D'25'
movwf SPBRG
bsf TRISC, 7 ; rc6 =TX
bcf TRISC, 6 ; rc7 = RX
bsf RCSTA, 7
;
; LCD CONFIG
clrf PORTD
movlw 0x00
movwf TRISD ;puerto D como salida
bsf TRISC, 3 ; SW 7
bsf PORTC, 3
bcf TRISA, 1
bcf TRISA, 2
bcf TRISA, 3
bcf PORTA, 1
bcf PORTA, 2
bcf PORTA, 3
movwf ADCON1
movlw 0x0F
bsf PORTA,3 ; EN = 1
bcf PORTA,1 ; RS = 0
movlw 0x38 ; 8-bit interface, character de 5x8
movwf PORTD
bcf PORTA,3 ; EN = 0
call delay
call reload_lcd
;;;;;;; SEND MESSAGES TO THE Bluetooth module
movlw 0x08
movwf TBLPTRH
movlw 0x60
movwf TBLPTRL
clrf TBLPTRU
call send_message
movlw 0x0D
call putc_usart
call write_lcd
call read_response
movlw 0x08
movwf TBLPTRH
movlw 0x80
movwf TBLPTRL
clrf TBLPTRU
call send_message
movlw 0x0D
call putc_usart
call write_lcd
call read_response
movlw 0x09
movwf TBLPTRH
movlw 0x00
movwf TBLPTRL
clrf TBLPTRU
call send_message
movlw 0x0D
call putc_usart
call write_lcd
call read_response
loop2 goto loop2
loop
call delay500
bsf PORTC, 0
goto loop
delay500
movlw 0x07
movwf 0x54
m3delay
movlw 0xFF
movwf 0x53
m2delay decfsz 0x53,1
goto m2delay
decfsz 0x54,1
goto m3delay
return
; read the response sent
read_response
movlw 0x61
movwf 0x0A
ciclin:
call getc_usart
cpfseq 0xA0
goto finciclin
goto fincicle
finciclin:
call write_lcd
goto ciclin
fincicle:
return
; send a character through USART
putc_usart
btfss PIR1, 4 ; checks that the flag is set = data ready
bra putc_usart
movwf TXREG
return
; recieve character through USART
getc_usart
btfss PIR1, 5 ; checks that the flag is set = data ready
bra getc_usart
movf RCREG, 0
return
;;;;
;Send a compossed message
send_message
looop
tblrd*+
movlw 0x2E
movwf 0x0C
movf TABLAT, 0
cpfseq 0x0C
goto g
goto g2
g
call putc_usart
call write_lcd
goto looop
g2
return
;;;
;LCD subroutines
write_lcd
bsf PORTA,3 ; EN = 1
bsf PORTA,1 ; RS = 1
movwf PORTD
bcf PORTA,3 ; EN = 0
call delay ;grande
return
delay movlw 0xFF
movwf 0x53
mdelay decfsz 0x53,1
goto mdelay
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Restart LCD
reload_lcd
;LCD ON - CURSOR OFF
bsf PORTA,3 ; EN = 1
bcf PORTA,1 ; RS = 0
movlw 0x0F ; LCD ON, Cursor ON
movwf PORTD
bcf PORTA,3 ; EN = 0
call delay
;CURSOR @ Home
bsf PORTA,3 ; EN = 1
bcf PORTA,1 ; RS = 0
movlw 0x02 ; cursor at home
movwf PORTD
bcf PORTA,3 ; EN = 0
call delay500 ;delay500
;Clear
bsf PORTA,3 ; EN = 1
bcf PORTA,1 ; RS = 0
movlw 0x01 ; Clear screen
movwf PORTD
bcf PORTA,3 ; EN = 0
call delay500
return
;
;******************************************************************************
;End of program
END
|
|
|