Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

by Reinoud on Wed Mar 13, 2013 3:34 pm

Hello adafruit! I have read your tutorial about the MCP23017 http://learn.adafruit.com/mcp230xx-gpio ... spberry-pi but I'm wondering how the I2C addressing works. I have read somewhere that it uses 7 bit addressing, but how can you control that with only three pins? I also read that the base address is 20, but somewhere else I read 40. How can I determine this from the datasheet?

I'm planning to make this addressing a bit flexible using headers and jumpers, do you recommend that I use pull down resistors on A0 to A2 (0 when open, 1 when closed)?
Reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 3:19 pm

by adafruit_support_bill on Wed Mar 13, 2013 5:48 pm

The addressing on the I2C bus uses 7 bits, but the MCP23017 base address is fixed at 0x20. With three bits of address offset on the chip, you can have it respond to addresses 0x20 to 0x27. The address pins can be tied directly to GND or VCC. A resistor will work, but is not needed.
User avatar
adafruit_support_bill
 
Posts: 25331
Joined: Sat Feb 07, 2009 9:11 am

by Reinoud on Wed Mar 13, 2013 6:32 pm

Thanks for the reply!

So I think the confusion (on my side) is that the address is in hex. 0100000 translates to 0x20 right? And 0100001 will translate into 0x21. But in this way the addressing is limited to 8 different addresses. Is this normal with these IC's? Or is the first part (0100) a sort of vendor ID?

I have this LCD display which is using the same range of addresses 0x20 - 0x27. Is there a way to use more addresses or should I use another IC brand?

regards,

Reinoud
Reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 3:19 pm

by adafruit_support_bill on Wed Mar 13, 2013 6:53 pm

The base address seems fairly arbitrary. I'm not sure that there is any rule for how they are chosen. Some devices do not have any further addressing capability. Others may have 1, 2 or 3 address lines to offset from the base address. If your LCD display is one of our display shields, it is based on an MCP230xx chip. If you need more than 8 of them, there is always the "soft I2C" option. You can create another I2C bus on any 2 free digital pins.
User avatar
adafruit_support_bill
 
Posts: 25331
Joined: Sat Feb 07, 2009 9:11 am

by tldr on Wed Mar 13, 2013 8:23 pm

how many more than 128 i/o pins do you need?

you could use one mcp23017 to set the address pins on a bunch of others on the fly. pretty sure it could work, but i'm having a little trouble wrapping my head around it at the moment. oops. i don't know if the chip checks its address once at power up or if it continually checks its address pins. probably in the data sheet. i'll check after dinner.

one thing, though. if you need a lot of switch inputs, the controller that adafruit uses for 8x8 matrices and 7 segment arrays is capable of scanning a 3x11 array of switches. i've got one on order to play with this weekend.
"If I had known it was harmless, I would have killed it myself." - Phillip K. Dick, A Scanner Darkly
User avatar
tldr
 
Posts: 464
Joined: Thu Aug 30, 2012 12:34 am

by Reinoud on Thu Mar 14, 2013 3:29 pm

tldr wrote:how many more than 128 i/o pins do you need?

you could use one mcp23017 to set the address pins on a bunch of others on the fly. pretty sure it could work, but i'm having a little trouble wrapping my head around it at the moment. oops. i don't know if the chip checks its address once at power up or if it continually checks its address pins. probably in the data sheet. i'll check after dinner.

one thing, though. if you need a lot of switch inputs, the controller that adafruit uses for 8x8 matrices and 7 segment arrays is capable of scanning a 3x11 array of switches. i've got one on order to play with this weekend.


Well it is not only i/o pins I want to connect... I have this LCD screen which uses the same addressing. This made me wonder if every IC I will use (in the future) uses the same addressing, I cannot connect more than 8 IC's on the bus...

I think the address is checked everytime you send data, right?
Reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 3:19 pm

by tldr on Thu Mar 14, 2013 5:24 pm

different devices will use different address, but the address space is small, (7 bits, 128 unique addresses), so i would guess that each manufacturer tries to avoid conflicts between their own devices.

the led matrix backpacks i mentioned before have a base address of 0x70. mostly just the luck of the draw, i guess.
"If I had known it was harmless, I would have killed it myself." - Phillip K. Dick, A Scanner Darkly
User avatar
tldr
 
Posts: 464
Joined: Thu Aug 30, 2012 12:34 am

by Reinoud on Fri Mar 15, 2013 12:45 am

tldr wrote:different devices will use different address, but the address space is small, (7 bits, 128 unique addresses), so i would guess that each manufacturer tries to avoid conflicts between their own devices.

the led matrix backpacks i mentioned before have a base address of 0x70. mostly just the luck of the draw, i guess.


Which IC is used in those backpacks?
Reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 3:19 pm

by adafruit_support_bill on Fri Mar 15, 2013 6:03 am

Which IC is used in those backpacks?

It is the HT16K33.
http://learn.adafruit.com/adafruit-led- ... 2c-address
User avatar
adafruit_support_bill
 
Posts: 25331
Joined: Sat Feb 07, 2009 9:11 am

by Reinoud on Fri Mar 15, 2013 7:59 am

adafruit_support wrote:
Which IC is used in those backpacks?

It is the HT16K33.
http://learn.adafruit.com/adafruit-led- ... 2c-address


Thanks!
Reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 3:19 pm