I2C addressing on MCP23017

Moderators: adafruit_support_bill, adafruit

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/
Locked
User avatar
reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 4:19 pm

I2C addressing on MCP23017

Post by reinoud »

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

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C addressing on MCP23017

Post by adafruit_support_bill »

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
reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 4:19 pm

Re: I2C addressing on MCP23017

Post by reinoud »

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

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C addressing on MCP23017

Post by adafruit_support_bill »

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.

tldr
 
Posts: 466
Joined: Thu Aug 30, 2012 1:34 am

Re: I2C addressing on MCP23017

Post by tldr »

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.

User avatar
reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 4:19 pm

Re: I2C addressing on MCP23017

Post by reinoud »

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?

tldr
 
Posts: 466
Joined: Thu Aug 30, 2012 1:34 am

Re: I2C addressing on MCP23017

Post by tldr »

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.

User avatar
reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 4:19 pm

Re: I2C addressing on MCP23017

Post by reinoud »

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?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C addressing on MCP23017

Post by adafruit_support_bill »

Which IC is used in those backpacks?
It is the HT16K33.
http://learn.adafruit.com/adafruit-led- ... 2c-address

User avatar
reinoud
 
Posts: 11
Joined: Wed Mar 13, 2013 4:19 pm

Re: I2C addressing on MCP23017

Post by reinoud »

adafruit_support wrote:
Which IC is used in those backpacks?
It is the HT16K33.
http://learn.adafruit.com/adafruit-led- ... 2c-address
Thanks!

Locked
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/

Return to “Adafruit Raspberry Pi® accessories”