Hello,
I am trying to use following code in a PIC18F14K50 to change configuration of a rn42 Bluetooth Module and it goes to command mode but then it gets stuck:
As an example I want to change name of bluetooth module and then reboot it.
Code:
DEFINE LOADER_USED 1
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 115200
DEFINE HSER_SPBRG 12
DEFINE HSER_CLOERR 1
DEFINE OSC 24
ADCON0 = 011100
ADCON1 = 000000
ADCON2 = 110101
ANSEL = 001000
ANSELH = 000011
TRISC.4 = 0
TRISC.0 = 0
TRISC.1 = 1
TRISB.5 = 1
TRISB.7 = 0
tx1 VAR PORTB.7
rx1 VAR PORTB.5
LED VAR PORTC.4
Mybutton VAR PORTC.1
mainloop:
If Mybutton = 0 Then
HIGH LED ' Turn on LED
Hserout ["$$$"] 'enter command mode
Pause 100
Hserout ["SN,MyBT"] 'Change name to MyBT
Pause 100
Hserout ["R,1"] 'Reboot
Pause 500
Else
LOW LED ' Turn off LED
Pause 500
Endif
Goto mainloop ' Do it forever
I receive the data on serial monitor when I use a UART-USB converter so I know the strings are being sent.
However,the module starts blinking after $$$ but it doesn't perform the rest of commands.The similar Arduino code works without any problem.
Any idea why it doesn't work?
Bookmarks