I2C issue


Closed Thread
Results 1 to 17 of 17

Thread: I2C issue

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107

    Default I2C issue

    I'm trying to use the uChip MCP4561 EEPOT. I can read from it just fine, I just can't do a write using I2CWRITE, and Microchip tells me that the device must have a NACK at the end of each data transfer in order to work properly.

    For example:

    If I want to WRITE two bytes tp address 0x5D, I use the code

    I2CAddress = $5D

    I2CWRITE SDA,SCL,I2CAddress, Command,[Byte1,Byte2]

    PBP sends out the WRITE request to the Address and gives an ACK
    It sends out the command and gives an ACK
    It sends byte 1 and gives an ACK
    It sends byte 2 and gives an ACK <- should give NACK here, since this is the last byte of the transfer.

    The MCP4561 holds the data bus low (forever). Is this a fault in PBP or my logic? In any case, does anyone know what I should try next?
    Last edited by Charles Linquis; - 17th October 2011 at 15:44.
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default Re: I2C issue

    Darrel can probably tell you how to mod a lib.
    In the mean time maybe SHIFTOUT will work?
    http://www.picbasic.co.uk/forum/cont...-EEPROM-Part-1
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: I2C issue

    Thanks for the link, I may have to use that technique. I'm currently setting up the hardware to do the WRITE.
    I already use it for READ.
    I have never been 100% successful in getting the HW WRITE to work, so I usually just fall back to bit
    banging. Fortunately, I'm hooked up to the real SDA and SCL on the chips.
    It was always real easy to do a master-slave thing by sending in software and receiving in hardware,
    you don't have to reconfigure any registers.

    And for those of you that want to play with I2C: If you use my interrupt-driven slave (posted on this forum), you can
    use I2CREAD and I2CWRITE at the same time the slave is running. One chip at both ends of the conversation!
    A great debugging tool.
    Charles Linquist

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: I2C issue

    Name:  I2C_using_shift.jpg
Views: 889
Size:  163.7 KBThe SHIFTOUT / SHIFTIN method does, indeed look like it is going to work. I get a lot more control over what is going on.
    I don't have eveything configured perfectly yet, but Thanks!
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default Re: I2C issue

    Cool!!!
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: I2C issue

    BUT --- I can't use the shiftin/shiftout commands to write I2C. It violates the open-collector spec. That leaves me with a couple of options:
    1. Learn to use the hardware
    2. Modify the library to give shiftin/shiftout an open-collector mode (like I already have with DEBUG)
    3. Do everything at the bit level myself.
    Charles Linquist

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