Uncategorized

mcp3017 discussion notes

https://imgur.com/gallery/NamPVPW

https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=233311&sid=dd08102315c70f062eddb819b59f57d0#p1429069

https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=233311&sid=dd08102315c70f062eddb819b59f57d0#p1429189

 

 

Asked 
Active today
Viewed 33 times
0

I 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 for ?

  • 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. – tlfong01 23 hours ago    
  • 1
    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? – Jack 22 hours ago
  • 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, … – tlfong01 22 hours ago    
  • (2) raspberrypi.org/forums/…. / top continue, … – tlfong01 22 hours ago   
  • 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? – Jack 21 hours ago

2

Look at the MCP23017/MCP23S17 datasheet.

As you rightly say the SPI protocol does not use those address bits, it uses chip select to address the device.

However the command set used by the device does use the address bits. The SPI control byte for the MCP23S17 uses those bits to select the device.

That allows you to have multiple MCP23S17 with one chip select but still be able to choose between them.

  • So selecting MCP23S17 is done via software, since they all share the same CS now ? am i right? – Jack 11 hours ago
  • 1
    Yes. If they share a chip select give them different addresses. However if they are behind a multiplexer you can give them the same address (but they still need an address). – joan 10 hours ago
  • oh thats a nice feature, ill just have to remove the multiplexer then saves me some parts, the address anyway has to pulled up/down – Jack 10 hours ago
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! 🙂 – tlfong01 21 hours ago   
Feeds

Feeds
yst 13:18
0

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
2329
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.

 

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

%d bloggers like this: