It looks like you have not quite decided whether to use the hardware serial port, or serin2/serout2. Once you decide which one you are using, you may have better luck. Let us know how it goes.
EDIT: Once again, beaten by Dave....
It looks like you have not quite decided whether to use the hardware serial port, or serin2/serout2. Once you decide which one you are using, you may have better luck. Let us know how it goes.
EDIT: Once again, beaten by Dave....
http://www.scalerobotics.com
Hi, I was happy when I got the GPS set to 9600 but yesterday I found out that it reset itself to 57600. I tried to reset it back to 9600 but failed and I tried it the whole afternoon...I use this as my reference http://www.laptopgpsworld.com/3701-d...ocosys-ls20031 it can only lowered to 38400, so I have no choice but to try this baudrate. My first time to use 20Mz crystal. I'm showing my codes when the GPS was running fine in 9600 baudrate. Please forgive my codings, still learning
Please help me make it run to 38400 baudrate, I have the 20Mz crystal.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
thanks in advance,
mbox
I am trying to run this code...I'm testing PC to MCU first, but I don't have response when entering $GPGGA,114708.600,1114.5089,N,12500.3864,E,1,6,1.6 7,23.5,M,55.4,M,,*69Code:define OSC 20 gpsin var portc.7 'rx gpsout var portc.6 'tx HH VAR byte MM VAR BYTE SS VAR BYTE ND VAR BYTE NM VAR BYTE NMD VAR WORD WD VAR BYTE WM VAR BYTE WMD VAR WORD AR VAR BYTE[20] START: SERIN2 gpsin,16572,[WAIT("$GPGGA"),WAIT(","),DEC2 hH,DEC2 mM,DEC2 sS,_ WAIT(","),DEC2 ND,DEC2 NM,WAIT("."),DEC3 NMD,WAIT(",N,"),_ DEC3 WD,DEC2 WM,WAIT("."),DEC3 WMD] PAUSE 1000 SEROUT2 gpsout,16572,[DEC2 HH,DEC2 MM,DEC2 SS,_ DEC2 ND,DEC2 NM,DEC3 NMD,DEC3 WD,DEC2 WM,DEC3 WMD,13,10] goto start
regards,
mbox
I manage to run this code for a start
I will update my codes with the Gps, and post it here later...Code:@ DEVICE HS_OSC DEFINE OSC 20 main: serout2 PortC.6,32774,["To PC",$D] ;@38400 To PC serout2 PortB.6,84,[$1B,$45] serout2 PortB.6,84,["To LCD"] ;@9600 To Lcd pause 500 goto main end
regards,
mbox
That is more like it.
Start small and build your way up![]()
Dave
Always wear safety glasses while programming.
I'm trying to add two numbers, 1st number is 140000 and the 2nd is 5377 which will give me 145377. And after getting the sum it will be divided by 60. x= (140000+ 537)/60, I think WORD can not hold much of the integers I need.
Ho do I do this in PBP?
Last edited by mbox; - 7th November 2010 at 15:27.
You are right, a word only goes up to 65535. If you have PBP v 2.5 or later, (and were using a PIC18 chip) you could select to use PBPL to compile, and define your large variables as LONG instead of WORD.
If you want to stick with the PIC16 series, you could use N-BIT math. http://www.picbasic.co.uk/forum/cont...153-N-Bit_MATH
By the way, it looks like you are using PM as your assembler.
You probably need to use MPASM for N-Bit Math to work. For that, you define your configs like this:Code:@ DEVICE HS_OSC
But you must comment out the configs in you C:/PBP/16F877A.INC file.Code:@ __config _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF
See : http://www.picbasic.co.uk/forum/cont...o-your-Program
Last edited by ScaleRobotics; - 7th November 2010 at 16:41.
http://www.scalerobotics.com
Bookmarks