Ran out of pins! Can I use an SD Card with SPI SS using an IOExpander?
Posted: Mon Mar 01, 2021 11:27 pm
Hi all,
This is my first ever post here, so please be gentle!
I've been banging my head for a while trying to get my SD Card working. My project is a bit unusual in that I've used up all the ESP32 pins, and also all 16 IO Expander pins are used up.
I've had to hack SparkFun's SD library to pull the SS pin high or low where required, using an MCP23017 over I2C to make this semi-work.
Here's the weird thing: I can get it to READ from the SDHD card (I can get volume info, etc), but if I attempt to WRITE a file, it never ends up on the card.
With SPI.begin() you can determine which pins you can use for MOSI, MISO, SCK and SS (okay, there's HSPI and VSPI pins (and FYI I'm using the VSPI pins), but of course, the SS pin is on another planet, so to speak, living on an MCP23017, reachable with an I2C transaction - this is the part of the code I've changed to make reading volume information work.
My gut says there's a bug somewhere, but I can't understand how or why as I'm pretty sure I've changed all the places in the SD library where the SS pin is set/changed.
Is/Has anyone experienced ANYTHING remotely similar to this issue? What would your advice be to move forward? I'm usually too shy to ask for help, but I'm totally stuck here, and I've been truly humbled by this experience... [which is code for a) stressed out, b) frustrated, c) absolutely lost]
If you need any further info, I'll be happy to elaborate... If anyone has some ideas to help me move forward I'd be extremely grateful and appreciative!
Thanks!
This is my first ever post here, so please be gentle!
I've been banging my head for a while trying to get my SD Card working. My project is a bit unusual in that I've used up all the ESP32 pins, and also all 16 IO Expander pins are used up.
I've had to hack SparkFun's SD library to pull the SS pin high or low where required, using an MCP23017 over I2C to make this semi-work.
Here's the weird thing: I can get it to READ from the SDHD card (I can get volume info, etc), but if I attempt to WRITE a file, it never ends up on the card.
With SPI.begin() you can determine which pins you can use for MOSI, MISO, SCK and SS (okay, there's HSPI and VSPI pins (and FYI I'm using the VSPI pins), but of course, the SS pin is on another planet, so to speak, living on an MCP23017, reachable with an I2C transaction - this is the part of the code I've changed to make reading volume information work.
My gut says there's a bug somewhere, but I can't understand how or why as I'm pretty sure I've changed all the places in the SD library where the SS pin is set/changed.
Is/Has anyone experienced ANYTHING remotely similar to this issue? What would your advice be to move forward? I'm usually too shy to ask for help, but I'm totally stuck here, and I've been truly humbled by this experience... [which is code for a) stressed out, b) frustrated, c) absolutely lost]
If you need any further info, I'll be happy to elaborate... If anyone has some ideas to help me move forward I'd be extremely grateful and appreciative!
Thanks!