You would be better off using SERIN2.
Here is a snippet from something .
Code:SERIN2 PORTB.2,16572,[WAIT("$GPGGA"),WAIT(","),DEC2 H,DEC2 M,DEC2 S,_ WAIT(","),DEC2 ND,DEC2 NM,WAIT("."),DEC3 NMD,WAIT(",N,"),_ DEC3 WD,DEC2 WM,WAIT("."),DEC3 WMD]
You would be better off using SERIN2.
Here is a snippet from something .
Code:SERIN2 PORTB.2,16572,[WAIT("$GPGGA"),WAIT(","),DEC2 H,DEC2 M,DEC2 S,_ WAIT(","),DEC2 ND,DEC2 NM,WAIT("."),DEC3 NMD,WAIT(",N,"),_ DEC3 WD,DEC2 WM,WAIT("."),DEC3 WMD]
Dave
Always wear safety glasses while programming.
Hi, I'm trying to understand SERIN2 command. why this code do not work when I entered "hello"?
regards,Code:Include "modedefs.bas" main: Serin2 PORTC.7, T9600, error, [WAIT("hello")] serout2 PortC.6, T9600, ["Valid"] goto main error: serout2 PortC.6, T9600, ["Invalid"] goto main end
mbox
I imagine many are thinking, "have you read the manual?".
Include "modedefs.bas"
Does nothing with SERIN2/SEROUT2.
T9600
Is for SERIN/SEROUT. "T" is for true mode anyways so if you are connecting directly to a PC you want INVERTED mode.
Appendix A from the manual has the modes for SERIN2. At 9600 baud the mode will be 16468. To see how that is calculated look here. http://www.picbasic.co.uk/forum/cont...SERIN2-SEROUT2
You will also want to specify a time for the GOTO LABEL "error".
Try this
The above will wait for 100 milliseconds, then GOTO "error" if "hello" is not received.Code:SERIN2 PORTC.7, 16468,100, error, [WAIT("hello")]
Dave
Always wear safety glasses while programming.
Hi mackrackit, thanks for the help, appreciated very much. I manage to run this code MCU to PC and use this guide http://melabs.com/resources/ser2modes.htmI know u have given me an example, but dont really get it ,Code:main: SERIN2 PORTC.7, 84,200, error, [WAIT("Hello")] serout2 PortC.6,84, ["Valid",10,13] goto main error: serout2 PortC.6, 84, ["Invalid",10,13] goto main end
Is there a way I could receive this value "$GPRMC,053740.000" and place it on a variable?
thanks and regards,
mbox
Last edited by mbox; - 2nd November 2010 at 00:00.
[WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]Code:H VAR BYTE 'HOURS M VAR BYTE 'MINUTES S VAR BYTE 'SECONDS [WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
Waits for GPRMC
[WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
Waits for ","
[WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
Places the first two digits into VAR H
[WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
Places the middle two digits into VAR M
[WAIT("$GPRMC"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]
Places the last two digits into VAR S
"$GPRMC,053740.000"
053740 =
H = 05 Hours
M = 37 Minutes
S = 40 Seconds
Dave
Always wear safety glasses while programming.
If you have not seen this it might be handy
http://aprs.gids.nl/nmea/
Dave
Always wear safety glasses while programming.
Hi, I want to try to use 38400 baud rate with 20Mz crystal. I want to test it first in the hyperterminal by entering this line "$GPGGA,115209.600,1114.5166,N,12500.3439,E,1,10,0 .83,16.9,M,55.4,M,,*5E" and I use this codebut I dont have any display on the recieve window. Please help..Code:DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 32 ' 38400 Baud @ -1.36% define HSER_BAUD 38400 DEFINE HSER_CLROERR 1 ' Clear overflow automatically 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 gpsin,16572,[DEC2 HH,DEC2 MM,DEC2 SS,_ DEC2 ND,DEC2 NM,DEC3 NMD,DEC3 WD,DEC2 WM,DEC3 WMD,13,10] goto START end
regards,
mbox
Bookmarks