+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2011
    Posts
    4

    Default SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working

    Using all the information found here on the forums (thanks to all that help answer questions on the forum) we have a working SERIN2 program. We would like to convert the program to HSERIN to hopefully gain efficiency, and possibly use the On Interrupt. (i.e. http://melabs.com/resources/samples/x1/pbp/serbufx.htm)
    Unfortunately we have been unable to receive any characters using HSERIN, but SERIN2 works great. HSEROUT also works great.

    This line works great...
    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]

    This line returns nothing but zeros (0)...
    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]

    Is HSERIN more involved than what I have shown in the below example (two examples shown, one SERIN and one HSERIN)? The HSEROUT works great, just as we would expect, but HSERIN receives nothing.

    Here is the entire working version with SERIN...
    '*********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 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
    serout2 GPSout,baud9600,[$A0, $A1, $00, $04, $05, $00, $02, $00, $07, $0D, $0A]
    '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
    serout2 GPSout,BAUD19200,[$A0, $A1, $00, $09, $08, $00, $00, $00, $00, $01, $00, $00, $00, $09, $0D, $0A]
    '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
    serout2 GPSout,BAUD19200,[$A0, $A1, $00, $03, $0E, $05, $00, $0B, $0D, $0A]
    'hserout [$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]
    '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

    Here is the HSERIN version, it only receives zeros...
    '*********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 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
    'serout2 GPSout,baud9600,[$A0, $A1, $00, $04, $05, $00, $02, $00, $07, $0D, $0A]
    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
    'serout2 GPSout,BAUD19200,[$A0, $A1, $00, $09, $08, $00, $00, $00, $00, $01, $00, $00, $00, $09, $0D, $0A]
    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
    'serout2 GPSout,BAUD19200,[$A0, $A1, $00, $03, $0E, $05, $00, $0B, $0D, $0A]
    hserout [$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]
    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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default Re: SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working

    Just a quick skim through and this caught my eye


    SerIn2 GPSin,baud19200

    Then you have
    SPBRG = 64 ' 9600 Baud
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default Re: SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working

    When using HSERIN/HSEROUT, you MUST use DEFINE. Then later, If you want to alter the baudrate of whatever else feature of the USART on the fly, then you use SPBRG, TXSTA, RCSTA.

    If I remember correctly, If you don't specify any DEFINE, PBP assume 2400 bauds.

    Another thing, always begin without timeout label for testing purpose, then add it. However, an ISR is more efficient.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jun 2011
    Posts
    4

    Default Re: SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working

    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

  5. #5
    Join Date
    Jun 2011
    Posts
    4

    Default Re: SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working

    Steve,

    Thanks for the reply. I did as you said and added the following...
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 129 ' 9600 Baud @ 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    It appears the "DEFINE HSER_CLROERR 1 ' Clear overflow automatically" line did it, as now everything works as expected.

    Thank you,

    Rodney

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default Re: SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working

    Yeah, that line is indeed handy. It also helps when SPBRG/TXSTA/RCSTA are properly set for the right OSC speed
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default Re: SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working

    Quote Originally Posted by mister_e View Post
    When using HSERIN/HSEROUT, you MUST use DEFINE.
    Then why does this work?
    Code:
    '******************************************
    '18F6680   02/14/09  INFEED PARSE TEST BAUD 9600
        DEFINE OSC 20
        @ __CONFIG    _CONFIG1H, _OSC_HS_1H
        @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
        @ __CONFIG    _CONFIG4L, _LVP_OFF_4L
        DEFINE LCD_DREG     PORTG 
        DEFINE LCD_DBIT     0
        DEFINE LCD_RSREG    PORTE 
        DEFINE LCD_RSBIT    0
        DEFINE LCD_EREG     PORTE 
        DEFINE LCD_EBIT     1
        DEFINE LCD_BITS     4 
        DEFINE LCD_LINES    4
        DEFINE LCD_COMMANDUS    3000 
        DEFINE LCD_DATAUS   150
        DEFINE HSER_EVEN
      '###############################################
        PAUSE 100 : LCDOUT $FE,1,"TEST"
        N1 VAR LONG:N2 VAR LONG
        START: N1 = 0 : N2 = 0
        HIGH PORTG.4 :PAUSE 250:LOW PORTG.4
        RCSTA.4 = 0 : RCSTA.4 = 1
        'CHANGE LINE FEED AND CARRIAGE RETURN AS REQUIRED 
        RCSTA=$90:TXSTA=$24:SPBRG=129:HSERIN[WAIT($a),WAIT($d),DEC N1,WAIT(","),DEC N2] 
        LCDOUT $FE,1,DEC N1 : lcdout $FE,$C0,DEC N2 : GOTO START
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default Re: SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working



    Oh humanity, I'm outdated now... Things changed then . At least you've cleared the CREN bit... but you want to monitor it later, unless it may stuck somewhere.

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default Re: SERIN2, SEROUT2,& HSEROUT works great, HSERIN not working

    I am printing that picture and putting it on the wall... in a frame even
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts