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!
Ran out of pins! Can I use an SD Card with SPI SS using an IOExpander?
Re: Ran out of pins! Can I use an SD Card with SPI SS using an IOExpander?
I will close the loop on this question. I managed to figure out what needed to be done, but it required a lot of patience, trial and error (and mostly confusion). In the end, the fix was pretty simple. There are "sdDeselectCard" and "sdSelectCard" methods in sd_diskio.cpp (in Sparkfun's SD library for ESP32 (Thank you SparkFun!). These functions are the best places to hook in custom code to support a convoluted way to set the CS pin by using an IO Expander. I have to admit that it was "eventually" pretty trivial to fix because it took a lot of my precious time to figure out what the "simple" fix should be!
Who is online
Users browsing this forum: No registered users and 56 guests