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?
Bookmarks