So today i finally sat down to the SPI modules i bought recently. I was most interested in the SD card slot, because i think having removable flash storage is better than having flash storage soldered on board and on the other hand the LCD screen seemed kinda scary.
I wrote some code, the way i usually like by making references to datasheet chapters etc. Everything was going well but the card did not work. I knew it was ok since it worked when plugged to my PC, but it was not responding to my init commands over SPI.
I googled and googled but nothing seemed to work. I tried my no-name logic analyzer but for some reason linux didnt recognise it - it used to work a few years ago but no more i guess.
Eventually i decided to check all the data that is being transmitted to the STM32 chip by changing all the writes into read/writes. Turns out MISO line was high all the time, non stop. This activated some alarm bell in me since it looked like an electrical error.
Eventually i found some random thread about arduino with what seemed to be a similar problem. What i did not mention is that SD cards work with 3.3v (afaik) which is not a big deal since stm32 also works on 3.3v. Sometimes one might want to plug them into a 5v circuit though and to accommodate that, the board i bought contained a voltage level regulator type of chip forgot the name. Essentially converter between 3.3. and 5v signals.
Apparently, in some cheaper no name modules like mine, this type of chip bugs out and keeps on holding the MISO line high despite the fact that SD card has let it go long time ago. This sounds like exactly what is happening to me.
Solution? Glorious:
Bypass the voltage converter. 3.3v should still be considered high state even by 5v circuits, so it should work.
I appreciate the random person who just bumped into a random thread after 2 years of inactivity and just dropped this knowledge. These folks are the backbone of the internet and im glad to have been in his position once or twice myself.
I myself did not feel like soldering that wire, especially since the pad on the socket is super small and these modules are very cheap. Since STM32 works on 3.3v anyways, and atmegas also have low voltage versions nowadays i decided to just buy another module which has no additional ICs on it - no voltage regulators, converters etc, just plain SD card socket and routed connections, maybe a resistor or two.
Funny thing in the end, but also kind of irritating, since it took me long enough to finally sit down and start tinkering with this stuff. Also it might turn out there's a different problem at play and i just bought some more electrojunk for no reason. But then again, i put some more sensors and SPI fun stuff into the basket when i was orderign the new module, so there's always new stuff to look forward to.
Oh also im using rust for this with rust-embassy, just because stm32 HAL is ugly and i dislike it very much. Rust has been great so far but it's kinda hard to find out how to do stuff outside of examples in their repo.















