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 Dec 1 '19 at 1:23
  • 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 Dec 1 '19 at 1:44
  • 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 Dec 1 '19 at 2:06
  • (2) raspberrypi.org/forums/…. / top continue, ... – tlfong01 Dec 1 '19 at 2:07
  • 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 Dec 1 '19 at 2:44

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.

|improve this answer|||||
  • 1
    So selecting MCP23S17 is done via software, since they all share the same CS now ? am i right? – Jack Dec 1 '19 at 13:35
  • 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 Dec 1 '19 at 14:34
  • 1
    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 Dec 1 '19 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.