Menu

Intermittent operation of HI2C

Help
MBB
2015-10-14
2015-10-20
  • MBB

    MBB - 2015-10-14

    I've been working with the HMC5883L electronic compass but was having problems with the HI2C NOT turning on when power was applied. This occured about 50% of the time. At first I thought it was a problem with the HMC5883L chip.

    Today I removed the HMC5883L chip from the circuit, deleted the code that used the HMC5883L, and connected pull up resistors to the PIC's HI2C SDL and SDA lines. The problem was still there! About half the time the PIC did not produce the Clock or Data signals when power was applied. Only the +5 volts from the pull up resistors appeared at the PIC's SDL and SDA ports.

    Below is the code I am uising. I would expect that the program to print "DoAgain", "START", and then get stuck in an endless loop printing "InLOOP" on the LCD. When it fails to turn on it prints "DoAgain" but nothing else, i.e. it hangs up at the 'HI2CStart' command.

    What am I doing wrong?

    ;Chip Settings
    #chip 18F4550,48
    #config PLLDIV=1, CPUDIV=OSC1_PLL2, OSC=HSPLL_HS, MCLRE=ON, LVP=OFF

    ;Defines (Constants)
    #define LCD_IO 2
    #define LCD_CB PORTC.1
    #define LCD_DB PORTC.2
    #define HI2C_BAUD_RATE 100
    #define HI2C_DATA PORTB.0
    #define HI2C_CLOCK PORTB.1
    #define HMC5883L_WRITE_address 60 ;0x3C
    '
    Dir HI2C_DATA in
    Dir HI2C_CLOCK in
    '
    HI2CMode Master
    '
    locate 0, 0
    print "Test_I2C"
    wait 1 s
    cls
    wait 500 ms
    '
    DoAgain:
    locate 0, 0
    print "DoAgain"
    '
    HI2CSTART
    locate 1, 0
    print "START"
    '
    Do
    HI2CReStart
    HI2CSend HMC5883L_WRITE_address'inidcate a write
    locate 1, 5
    print "InLOOP"
    loop While HI2CAckPollState

    HI2CSTOP
    '
    Goto DoAgain

     
  • Anobium

    Anobium - 2015-10-14

    You are doing nothing incorrect. In the next release there is a new hardware i2c driver and the release includes a fully test compass driver. There is a low level issue.

    Send me an Personal Message and I will provide you the latest build. It would be good to get you to test the release. You need release candidate 013. Earlier versions will not fix your issue.

    Anobium

     
  • Anobium

    Anobium - 2015-10-14

    Sorry, I should make it clear. You have hit a known issue that is resolved in the next release.

     
  • MBB

    MBB - 2015-10-15

    0.13 fixed it!

    Thanks.

     
  • Anobium

    Anobium - 2015-10-15

    Wonderful news.

    I messed up the code in the v0.94 release for HWI2C 18f support! I admit it! :-)

     
  • Edward LaBudde

    Edward LaBudde - 2015-10-16

    Evan where do I find release 13? Thanks, Ed.

     
    • Anobium

      Anobium - 2015-10-17

      I just sent you a PM with the lastest build version and location.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.