SERIN2 = ok, HSERIN = no!


Closed Thread
Results 1 to 29 of 29

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 = ok, HSERIN = no!

    If I remove the WAIT modifier following the HSERIN command, I will receive data and see it.

    But, just if I would have a wrong setting (i.e. wrong baudrate or polarity), I get strange characters on the LDC display.

    What's the missing/wrong setting....
    Roger

  2. #2
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default Re: SERIN2 = ok, HSERIN = no!

    Finally I made it work by using a MAX232 between the GPS module and the PIC.

    My conclusion is that the use of USART (HSERIN/HSEROUT) will set higher and lower voltage thresholds on the PIC's pins as it does when using "simple" serial communication via SERIN/SEROUT commands. Couldn't find anything about that in the DS...or am I blind?

    I go back to SERIN2 and its reduced number of components application


    The "working" code is:
    Code:
    'Config Directive settings for MPASM (fuses) for 18F2420
    @ __CONFIG _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H ;_OSC_INTIO7_1H
    @ __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L & _BORV_0_2L
    @ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_1_2H
    @ __CONFIG _CONFIG3H, _MCLRE_OFF_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_PORTBE_3H
    @ __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    @ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L
    @ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
    @ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L
    @ __CONFIG _CONFIG6H, _WRTB_OFF_6H & _WRTC_OFF_6H & _WRTD_OFF_6H
    @ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L
    @ __CONFIG _CONFIG7H, _EBTRB_OFF_7H & _DEVID1 & _IDLOC0
     
    'Registers
    ADCON1  = %00001111     'Turn off all AD's (= "_PBADEN_OFF_3H")        
    TRISC   = %11000000     'stated by DS(!)
    RCSTA   = %10010010     'enable serial port, enable continuous receive, automatic clear overrun error
    TXSTA   = %00000000     'disable transmit, BRGH=0
    BAUDCON = %01101000
    SPBRG   = 51            '9600 Baud @ 8MHz, 0.16%
    SPBRGH  = 0
     
    '-------------------------------------------------------------------------------
    ' DEFINEs
    DEFINE OSC 8
     
    DEFINE LCD_DREG PORTB   'LCD data port 
    DEFINE LCD_DBIT 0       'LCD data starting PORT.bit (0 or 4)
    DEFINE LCD_RSREG PORTC  'LCD register select port 
    DEFINE LCD_RSBIT 4      'LCD register select bit 
    DEFINE LCD_EREG PORTC   'LCD enable port 
    DEFINE LCD_EBIT 5       'LCD enable bit 
    DEFINE LCD_BITS 4       'LCD bus size 4 or 8 
    DEFINE LCD_LINES 2      'Number lines on LCD 
     
    '-------------------------------------------------------------------------------
    INIT:
    GPS_D   VAR BYTE(80)    'Incomming data bit array
    LED0    VAR PORTA.5     'alive LED
     
    '-------------------------------------------------------------------------------
    ' DOGM LCD display specific settings
    PAUSE 1000              'Time to settle Vdd
    LCDOUT $FE, $29         'Function Set: 4 bits bus mode
    LCDOUT $FE, $1C         'Bias set
    LCDOUT $FE, $52         'Power control + Contrast (HiByte)(for 5V=$52/3,3V=55)
    LCDOUT $FE, $69         'Follower control  (5V=$69/3,3V=6D)
    LCDOUT $FE, $78         'Contrast (LowByte)
     
    '-------------------------------------------------------------------------------
    ' Main loop
     
    LCDOUT $FE,2,"HSERIN"
      
    MAIN:
      
      HSERIN [WAIT("$GPGGA,"),STR GPS_D\6]
     
      LCDOUT $FE,2,GPS_D(0),GPS_D(1),":",GPS_D(2),GPS_D(3),":",GPS_D(4),GPS_D(5)
      
      TOGGLE LED0
     
      GOTO MAIN:
    Roger

Members who have read this thread : 0

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

Posting Permissions

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