It's a bit confusing, isn't it?
The expanders "address" goes in the I2C Control byte, and the "command" goes in the Address byte.
Read Input Ports:
I2Cread PORTB.2,PORTB.3,64,0,[switch(0),switch(1)]
Write Output Ports:
I2Cwrite PORTB.2,PORTB.3,64,2,[switch(0),switch(1)]
Set Port Configuration:
PE_TRIS VAR BYTE[2] ; bitwise - 1=input 0=output
PE_TRIS(0) = 255 ; Port1 all input
PE_TRIS(1) = 0 ; Port2 all output
I2Cwrite PORTB.2,PORTB.3,64,6,[PE_TRIS(0),PE_TRIS(1)]
For a second Expander, you would tie pin <strike>AD1</strike> AD0 to Vdd to change it's slave address to 66. Then you can use it just like the first one.How do I set the 2nd MAX7311's Port1/Port2 registers to output?
Read Input Ports:
I2Cread PORTB.2,PORTB.3,66,0,[switch(0),switch(1)]
Set Port Configuration: (all output)
I2Cwrite PORTB.2,PORTB.3,66,6,[0,0]
HTH,
Bookmarks