Code:
clear
Include "modedefs.bas"
H VAR BYTE[2]
TRISD = %00000000 ' PortD.0 LCD connection
TRISC = %10000000 ' PortC.6 as tx and PortC.7 as rx
TRISB = %00000001 ' PortB.0 as rx from GPS
PortB = %00000000
PortD = %00000000
'This following serout2 command is use for bluetooth initialization
SerOut2 PortC.6,84, [$02,$52,$27,$06,$00,$7F,$12,$13,$23,$17,$09,$00,$03]
pause 200
SerOut2 PortC.6,84, [$02,$52,$66,$00,$00,$B8,$03]
pause 200
Serout2 PortC.6,84, [$02,$52,$04,$11,$00,$67,$10,$4D,$49,$43,$52,$4F,$42,$4F,$58,$42,$54,$31,$20,$20,$20,$20,$00,$03]
RX var byte ' Receive byte
serout PortD.0,T9600,[$1B,$45]
serout PortD.0,T9600,["Loging on.."]
pause 300
''Main Code
Pause 1000
serout PortD.0,T9600,[$1B,$45]
serout PortD.0,T9600,["**GPS Locator**"]
Menu:
pause 200
'****** [Menu setup on PC screen] *************************
serout PortD.0,T9600,[$1B,$45,"**System Ready**"]
Receive:
' ***** [Receive the menu selection from Bluetooth receiver] ***************
serin PortC.7, T9600, RX 'Receive menu from Bluetooth
'serout PortD.0,T9600,[$D,RX] 'Check Input
RX = RX - $30 'Convert ASCII to decimal value
If RX > 1 then Error ' Test for good value
Branch RX, [zero, one] 'redirect to menu selection code
error:
serout2 PortC.6, 84, ["Oops Try again ",#RX,10,13]
goto menu
Zero:
'***** [ Code for zero value ] *****************************
goto menu 'Return to menu, zero is not a valid selection
One:
'***** [Code for selection 1] ************************
;serout PortD.0,T9600,[$D,"Request ",#rx]
;serout PortD.0,T9600,[$1B,$45,"**System Ready**"]
;serout PortD.0,T9600,[$D,"Data sent"]
SERIN2 PORTB.0, 84,40, error,[WAIT("$GPRMC"),WAIT("A,"),str H\24]
pause 500
serout2 PortC.6, 84, [str H\24,10,13] 'Send data to bt
' example output: 1114.5089,N,12500.3864,E
pause 500
goto menu 'Return to main menu
goto menu
End
Please help me make it run to 38400 baudrate, I have the 20Mz crystal.
Bookmarks