Can I put SPI SS pins on a MCP23008 Port Expander?

Typically you can override the default SS pin by passing a SS pin to the SPI.begin function. If we want to put our SS pin on a MCP23008 port expander how can I handle this?

Thanks

@incorvia,

I’m not sure but it sounds like you can stick to using the default SS pin when one is not specified (though you won’t be able to use it) and toggle the SS pin manually using code before and after each transfer.

1 Like

I see now that the documentation says:

Note: The SPI firmware ONLY initializes the user-specified slave-select pin as an OUTPUT. The user’s code must control the slave-select pin with digitalWrite() before and after each SPI transfer for the desired SPI slave device. Calling SPI.end() does NOT reset the pin mode of the SPI pins.

So it seems you are right that if I set the pin as an output myself and bring it high or low it will have the desired effect. Thanks!

2 Likes

@incorvia, you can specify an SS pin in the call the to SPI.begin(), however all the call will do is set the pin to INPUT mode. Your own code needs to manage the pin itself. The default SS pin is A2.

2 Likes

That said, “your own code” also implies contributed libraries since they usually also take a SS pin parameter to do the handling internally. So if you control your SS pin and use a lib that also uses SPI you need to be a good citizen and immediately release your SS after you’re done so other devices can be selected without collision.

1 Like

Thanks everyone for the responses. I believe I have a good sense of the issue now!

1 Like

@incorvia, can you post a quick update on the issue and the solution so future readers can see the resolution? :wink:

2 Likes