Obd2


Closed Thread
Results 1 to 3 of 3

Thread: Obd2

  1. #1
    Join Date
    Mar 2016
    Posts
    10

    Default Obd2

    Hi. I have been having problems with HSERIN. I am talking to a ELM327 IC with a PIC16F876A via the TX / RX pins. when I send data (ATZ for example) to the ELM327 through its RX pin from the PIC and have its TX pin connected to a terminal program everything works. I get the "ELM321 V1.2" message. Now when I connect the ELM327 TX pin to my RX pin on the PIC and try to display it on a 2X16 serial display I get same message as would be expected. But that's it. nothing else will display when I send another command. It seems to be stuck at the HSERIN command. I have a debug led in the loop and it stops blinking. So I know it stops there. Some how the RS232 data coming from the ELM327 is locking up HSERIN. If I toggle power it works for the first message again. no others.

    Any ideas what is going on with the HSERIN that I am doing wrong?

    Below is my test code.




    DEFINE OSC 20

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h '20
    DEFINE HSER_BAUD 38400

    ADCON0 = %00000000
    ADCON1 = %00000110

    'TRISA = %00000000
    'TRISB = %00000000
    TRISC = %10000000


    OBD_DATA VAR WORD

    TX0 VAR BYTE
    TX1 VAR BYTE


    RX0 VAR BYTE
    RX1 VAR BYTE
    RX2 VAR BYTE
    RX3 VAR BYTE
    RX4 VAR BYTE
    RX5 VAR BYTE
    RX6 VAR BYTE
    RX7 VAR BYTE
    RX8 VAR BYTE
    RX9 VAR BYTE
    RX10 VAR BYTE
    RX11 VAR BYTE
    RX12 VAR BYTE
    RX13 VAR BYTE
    RX14 VAR BYTE
    RX15 VAR BYTE


    '****************************** VARIABLES **************************************

    TX0 = 01 '01
    TX1 = 12 '0C


    '****************************** PROGRAM ****************************************


    START:

    'HSerout [65,84,90,13,10] 'SEND ATZ (13 = CR) (10 = LF)

    'HSerout [HEX2 TX0,HEX2 TX1,13,10] 'GET RPM EITHER OR WORKS

    HSerout ["010C",13,10] 'GET RPM


    HSerin 100,START,[RX0,RX1,RX2,RX3,RX4,RX5,RX6,RX7,RX8,RX9,RX10,RX11, RX12,RX13,RX14,RX15]

    HIGH PORTC.1 'FOR DEBUG
    PAUSE 500
    LOW PORTC.1

    SerOut2 PORTC.3,16468,5,[254,128," RPM "]
    SerOut2 PORTC.3,16468,5,[254,192,RX0,RX1,RX2,RX3,RX4,RX5,RX6,RX7,RX8,RX9,RX 10,RX11,RX12,RX13,RX14,RX15]


    GoTo START



    Thanks for any help.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Obd2

    Try adding

    DEFINE HSER_CLROERR 1 ' Clear error automatically when encountered

  3. #3
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Obd2

    Could it be the spaces in your Hserin and serout statements causing the problem?

Members who have read this thread : 1

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