Uncategorized

mcp23017 addressing discussion notes

Q: can the MCP23S17 address pin be ignored?

JackI am planning on using the MCP23S17 port expander for my use case but upon wiring them up , it would seem that the MCP23S17 which is the SPI version of the port expander has address pins which is weird. The SPI protocol does not need addresses but instead rely on the Chip Select pin. What is this…

tlfong01

tlfong01
Ah let me see. The address decoding pins A2, A1, A0, are for you to select one of up to 8 MCP23S17s (See Datasheet Section 3.3). If you have only one MCP23S17, then you can connect those three pins to ground (CANNOT leave them floating) and use 000 to select the MCP23017: imgur.com/gallery/NamPVPW.
Jack

Jack
I do have multiple MCP23S17s but hook them up to a 3 to 8 line decoder 74HC138, i apologize i still dont quite get it, So are you saying that i still have to adjust the address kind of like i2c ? So , the CS pin can be shared by multiple MCP and have to adjust the address manually?
tlfong01

tlfong01
2339
Ah, let me see. I did once used HC137/138 and similar in my Arduino Decimilla days. But when I started leaning SPI and I2C, I found they can replace the MUX/DEMUX chips. Actually I did not even use any Rpi CS0/CS1 pins, I just use GPIO pins instead. This way I can have say, 10 GPIO pins as CS0~9 pins. Later I even forgot the CPIO pins and used MCP23018 GPIO pins as CS pins. In other words, with one MCP23017, I can have 16 CS pins! 🙂 (1) raspberrypi.org/forums/…, / to continue, …
(2) raspberrypi.org/forums/…. / top continue, …
Jack
Jack
yes, i have no problem on my chip selects. Its those address pins that are kinda throwing me off. Can i leave A2,A1,A0 to ground on all my MCP devices?
tlfong01

tlfong01
Yes, you can keep your old timer’s HC138s to demux MCP23S17s. Just short all the A2,1,0 pins to ground and pretend they don’t ever exist. But then hackers watching this forum would LOL, thinking that the general hardware IQ here is a bit low and thus damaging this forum’s reputation! 🙂
Jack
Jack
yst 13:18
Its my first time seeing an address in SPI protocol, what are those for then ?
tlfong01

tlfong01
Ah let me see. You earlier commented that “So are you saying that i still have to adjust the address kind of like i2c, …”. Yes, I2C doesn’t have CS signals, and their using A2,1,0 to select modules are similar. Perhaps I can try to find a good example to explain the common use of hardware address decoding pins.
22 hours later…
tlfong01

tlfong01
2339
11:15
I read our discussion again and found that the confusion is caused by three “selection” schemes (a) Select I2C bus (eg, I2C0 or I2C1 etc) or SPI bus (eg. SPI1, or SPI2 etc), (2) Select Device (eg, at Device Address 0x02, 0x21, to 0x2f etc), (3) Select register (eg, at register addresses 0x00 to 0xff).
At the highest level, selecting I2C bus or SPI bus uses different methods. But at the lower levels, selecting device addresses 0x20 to 0x2f, and register addresses 0x00, 0x01 etc) are basically the same.
So perhaps I would use I2C MCP23017 to look how to select device and register as an example. Once I2C case is understood, SPI case is also understood. Then we can go up one level to look at selecting I2C and SPI bus.
I know it is still confusing. Perhaps using real module wiring examples (eg, A2, A1, A0) and programming examples (just one or two sample registers) help explain better. I would pause here.
If you agree with my learning plan, then I would move on. Comments and counter suggestions welcome! 🙂
.END

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s