Dave, thanks for the response.
The SerIn2 GPSin,baud19200 is only used in the first example (SERIN2 example). And SPBRG = 64 ' 9600 Baud is only used in the second example (HSERIN). I was trying to show the two versions of the code, side by side, in my above post, but I cleaned them up below, removing the committed lines of code from each example. Both examples should (or that is our intention) accomplish the same thing. At first look, I though it could be hardware, but we are using RC6/TX and RC7/RX, and not changing any hardware when we go from SERIN2 to HSERIN. Keep in mind that SERIN2 works great.
Here is the entire working version with SERIN2...
Code:
'*********Constants, Variable and Defines***************
' Setup Chip Oscillator This is also in the .INC file provided by MeLabs and
' Needs to be comminted out in the MeLabs .INC file (C:\PBP\18f2420.inc)
'Oscillator system clock switch and Oscillator Selection bits
@ __CONFIG _CONFIG1H, _OSC_HS_1H
'Brown-Out Reset & Brown-out Reset enabled in hardware only (SBOREN is disabled) & 3.2 volt Minimum setting
@ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_SBORDIS_2L & _BORV_3_2L
'Watchdog Timer Enable and Timer Postscale Select bits
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
'CCP2 input/output is multiplexed with RC1 & PORTB<4:0> pins are configured as digital I/O on Reset &
'Timer1 configured for higher power operation & MCLR pin enabled; RE3 input pin disabled
@ __CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
'Stack full/underflow will cause Reset & Single-Supply ICSP disabled & Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
@ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
' SETUP CHIP CLOCK SPEED
DEFINE OSC 10
'pinouts for Serout2 commands:
GPSin VAR PORTC.7 ' GPS transmit, PIC recieve pin
TRISC.7 = 1 ' Set PORTC, pin 1 to an input
GPSout var PORTC.6 ' GPS recieve, PIC transmit pin
TRISC.6 = 0 ' Set PORTC, pin 6 to an output
CSpic VAR PORTB.1 ' SPI "Chip Select PIN"
TRISB.1 = 1 ' Set PORTB, pin 1 to an input
PICout var portC.5 ' Pic Serial Data Output pin
'Allocate Constants for Serial Com
TimeOut CON 3 'Serial port input time out
baud9600 CON 84 '9600 baud
baud19200 con 32 '19200 baud Driven True None 32
'Allocate Variables for GPS:
knots VAR WORD 'Calculated knots
fps VAR WORD 'Feet Per Second Calculated
fpm VAR WORD 'Feet Per Minute Calculated
GPSUTCtimehh var byte 'GPS UTC Time hh (hhmmss.sss)
GPSUTCtimemmss var word 'GPS UTC Time mmss (hhmmss.sss)
GPSmsec var word 'GPS UTC sss (hhmmss.sss)
GPSStatus var byte 'GPS Status string V = 86 = Nav Receiver Warning; A = 65 = Data Valid
GPSSpeed var word 'GPS Speed over ground
GPSSpeedtenth var byte 'GPS Speed over ground tenths
GPSCourse var word 'GPS Course over ground
GPSCoursetenth var byte 'GPS Course over ground tenths
fpm = 0
ADCON1 = 15 'Set all pins as digital on PIC18F2420
high picout 'needed to start the serout communication, if we don't idle the PICout line high then the serin on the other pic hangs
pause 3000 'wait for GPS module to turn on before sending commands
'Setup Serial Port Baud rate to 19200 from 9600
serout2 GPSout,baud9600,[$A0, $A1, $00, $04, $05, $00, $02, $00, $07, $0D, $0A]
pause 1500
'Setup NMEA Message to only send RMC - Recommended Minimum Specific GNSS Data, turn all other messages off
serout2 GPSout,BAUD19200,[$A0, $A1, $00, $09, $08, $00, $00, $00, $00, $01, $00, $00, $00, $09, $0D, $0A]
pause 1500
'Setup the Position Rate of GPS module TO 5Hz
serout2 GPSout,BAUD19200,[$A0, $A1, $00, $03, $0E, $05, $00, $0B, $0D, $0A]
pause 3000
GPS:
SerIn2 GPSin,baud19200,Timeout,Nostring,[WAIT("$GPRMC,"),dec2 gpsutctimehh,DEC4 gpsutctimemmss,skip 1,dec3 gpsmsec,skip 1,GPSstatus,skip 28,dec4 GPSspeed,skip 1,dec2 gpsspeedtenth,skip 1, dec3 gpscourse,skip 1, dec2 gpscoursetenth]
NoString: 'if no data is receivd we still need to continue through routine
knots = gpsspeed * 100 + gpsspeedtenth
fps = (knots * 169)/10000 'knots * 1.68781 = fps
fpm = (knots * 101)/100 'knots * 101.2686 = fpm
if CSpic = 0 then goto gps
serout2 picout,baud19200,[dec5 gpsstatus]
goto GPS
EndError:
end
Here is the HSERIN version, it only receives zeros...
Code:
'*********Constants, Variable and Defines***************
' Setup Chip Oscillator This is also in the .INC file provided by MeLabs and
' Needs to be comminted out in the MeLabs .INC file (C:\PBP\18f2420.inc)
'Oscillator system clock switch and Oscillator Selection bits
@ __CONFIG _CONFIG1H, _OSC_HS_1H
'Brown-Out Reset & Brown-out Reset enabled in hardware only (SBOREN is disabled) & 3.2 volt Minimum setting
@ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_SBORDIS_2L & _BORV_3_2L
'Watchdog Timer Enable and Timer Postscale Select bits
@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
'CCP2 input/output is multiplexed with RC1 & PORTB<4:0> pins are configured as digital I/O on Reset &
'Timer1 configured for higher power operation & MCLR pin enabled; RE3 input pin disabled
@ __CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
'Stack full/underflow will cause Reset & Single-Supply ICSP disabled & Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
@ __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
' SETUP CHIP CLOCK SPEED
DEFINE OSC 10
CSpic VAR PORTB.1 ' SPI "Chip Select PIN"
TRISB.1 = 1 ' Set PORTB, pin 1 to an input
PICout var portC.5 ' Pic Serial Data Output pin
'Allocate Constants for Serial Com
TimeOut CON 3 'Serial port input time out
baud9600 CON 84 '9600 baud
baud19200 con 32 '19200 baud Driven True None 32
'Allocate Variables for GPS:
knots VAR WORD 'Calculated knots
fps VAR WORD 'Feet Per Second Calculated
fpm VAR WORD 'Feet Per Minute Calculated
GPSUTCtimehh var byte 'GPS UTC Time hh (hhmmss.sss)
GPSUTCtimemmss var word 'GPS UTC Time mmss (hhmmss.sss)
GPSmsec var word 'GPS UTC sss (hhmmss.sss)
GPSStatus var byte 'GPS Status string V = 86 = Nav Receiver Warning; A = 65 = Data Valid
GPSSpeed var word 'GPS Speed over ground
GPSSpeedtenth var byte 'GPS Speed over ground tenths
GPSCourse var word 'GPS Course over ground
GPSCoursetenth var byte 'GPS Course over ground tenths
fpm = 0
ADCON1 = 15 'Set all pins as digital on PIC18F2420
high picout 'needed to start the serout communication, if we don't idle the PICout line high then the serin on the other pic hangs
pause 3000 'wait for GPS module to turn on before sending commands
' Setup Hardware Serial Input, use instead of defines, so it can be changed
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 64 ' 9600 Baud @ 0.16%
'Setup Serial Port Baud rate to 19200 from 9600
hserout [$A0, $A1, $00, $04, $05, $00, $02, $00, $07, $0D, $0A]
pause 1500
RCSTA = 0 ' Disable serial port & continuous receive
SPBRG = 32 ' 19200 Baud @ -1.36%
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
'Setup NMEA Message to only send RMC - Recommended Minimum Specific GNSS Data, turn all other messages off
hserout [$A0, $A1, $00, $09, $08, $00, $00, $00, $00, $01, $00, $00, $00, $09, $0D, $0A]
pause 1500
'Setup the Position Rate of GPS module TO 5Hz
hserout [$A0, $A1, $00, $03, $0E, $05, $00, $0B, $0D, $0A]
pause 3000
GPS:
hserin Timeout,Nostring,[WAIT("$GPRMC,"),dec2 gpsutctimehh,DEC4 gpsutctimemmss,skip 1,dec3 gpsmsec,skip 1,GPSstatus,skip 28,dec4 GPSspeed,skip 1,dec2 gpsspeedtenth,skip 1, dec3 gpscourse,skip 1, dec2 gpscoursetenth]
NoString: 'if no data is receivd we still need to continue through rutine
knots = gpsspeed * 100 + gpsspeedtenth
fps = (knots * 169)/10000 'knots * 1.68781 = fps
fpm = (knots * 101)/100 'knots * 101.2686 = fpm
'fpm = fpm + 1 'used for testing
if CSpic = 0 then goto gps
serout2 picout,baud19200,[dec5 gpsstatus]
goto GPS
EndError:
end
Thanks
Rodney
Bookmarks