accessing multiple MCP23016s


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151

    Default accessing multiple MCP23016s

    Hello All-
    With great help from this forum, I have the ability to read and write to a MCP23016. I now want to read and write to the max which is 8 of these on one I2C line.

    In debugging and troubleshooting - and learning, it looks as if the 23016s are addressed not one after the other (addr $40 for device zero, addr$41 for device 1, etc) but skipping one address such as $40 for the 1st device at address0 then $42 for the second device at address1, and so on which does not make sense.

    This is not what I read from the datasheet or from other examples on this forum.

    Partial code below which reads from the device. I use PORT0 for output and PORT1 for inputs.

    iaddr=$40 '1st switch board's address
    i2cread idata,iclock,iaddr,ireg,[switches[0]]
    pause 20
    iaddr=$42 '2nd switch board's address
    i2cread idata,iclock,iaddr,ireg,[switches[1]]
    pause 20
    iaddr=$44
    i2cread idata,iclock,iaddr,ireg,[switches[2]]
    pause 20
    iaddr=$46
    i2cread idata,iclock,iaddr,ireg,[switches[3]]
    pause 20

    I get back data and can write to the device so I think I got it, but it does not agree with the datasheet.

    What am I doing wrong?

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


    Did you find this post helpful? Yes | No

    Default

    It's about normal

    Code:
    CONTROL WORD
    ------------
    BIT7 	BIT6 	BIT5 	BIT4 	BIT3 	BIT2 	BIT1 	BIT0
    0	1	0	0	A2	A1	A0	R/W	
    0	1	0	0	0	0	0	x	40
    0	1	0	0	0	0	1	x	42
    0	1	0	0	0	1	0	x	44
    0	1	0	0	0	1	1	x	46
    0	1	0	0	1	0	0	x	48
    0	1	0	0	1	0	1	x	4A
    etc etc etc
    BIT0 is handled by PBP.
    Last edited by mister_e; - 19th May 2008 at 23:33.
    Steve

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

  3. #3
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Thumbs up Brain Drain

    Well yes, you are absolutely correct!
    I completely forgot the R/W bit was counted.........
    Time to go to sleep or grab a wine glass <grin>!

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    Try both
    Steve

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

  5. #5
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Question I2C bus waveforms

    Mr. E (or anyone <grin>-
    What is the 'best' way to bus these 23016s off board? I will have 8 of these devices on their own I/O board and looking at the waveforms on 3 of them - the multi-ground cable may not be the best solution.

    The leading edge of the waveform rounds off to the falling edge of the pulse. The cable I have selected is instrument-grade but without a foil shield. I am sending +5 with the 2 signals but I do have 3 ground wires and the twist in the cable should have been good enough for the 1 foot of cable between the 8 boards.

    The proc is in the middle and 4 boards go out from the left and right.

    Should I use a schmidt buffer?

  6. #6
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default From 4.7k to 2.2k pullups

    I changed the pullups to 2.2k based on the graph in the I2C specs of 2000. I believe since I am using all MCP23016s and they are 'fast' devices, I should be fine.

    The waveforms have a bit of roll-off on the leading edge but look better.

    Has anyone used the switched pull up circuit from this refrence?

Similar Threads

  1. Multiple PICS from Same Crystal?
    By WOZZY-2010 in forum General
    Replies: 2
    Last Post: - 6th February 2010, 15:18
  2. Multiple Pics accessing single EEPROM
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd February 2008, 17:22
  3. Multiple Pics to One serial port
    By Rleonard in forum Serial
    Replies: 1
    Last Post: - 18th January 2007, 18:30
  4. Multiple SERIN's
    By JoeR in forum mel PIC BASIC
    Replies: 4
    Last Post: - 6th October 2005, 22:22
  5. Using Multiple EEPROMs
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th March 2005, 07:37

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