I have had this issue for the last couple of days and I cannot solve it. There are many similar issues I've read through online but they have not really worked for me.
This project involves a PCB and doesn't use the Arduino type SD card breakout although it is Arduino based.
In the microcontroller schematic I have ticked in red marker the connections from the microcontroller to the SD card
I am using the original chip select pin SS (CS_1) for the SD card, and PB4 (CS_2) as the chip select for a CAN controller.
I am fairly sure the SPI interface is working OK because the CAN controller initialises (if I purposely use the wrong SS pin for CAN, it throws an error)
The SD card schematic is also attached. Basically CS_1 from the micro goes to HC4050, and this is level shifted (CS_µ) to the SD card reader. Similarly for MOSI and SCLK. I have not level shifted the MISO line because a schematic I found online earlier did not do so either (but I have forgotten which schematic it is now...) I did check the adafruit SD card breakout schematic and they don't appear to level shift MISO.
Both the SD card reader and the HC4050 receive 3.3V when tested with a multimeter. For further testing I borrowed an Arduino MICRO from a friend and hooked up an Arduino style SD card breakout, ran the same code and it worked fine.
I used an Arduino MICRO for testing because the microcontroller on the PCB has the same bootloader flashed through the Arduino IDE.
The thing to note is that the SD card breakout is not exactly the same implementation as the adafruit or mine as it uses an LVC125 Buffer and a bunch of resistors instead of the HC4050
It looks like this: https://howtomechatronics.com/wp-content/uploads/2016/08/Arduino-SD-Card-Module.jpg
Code for initialising the SD card is as below, I am using the SD.h library.
//SETUP microSD CARD
if ( SD.begin( ) )
{
Serial.println( "SD card initialised" );
}
else
{
Serial.println( "Unable to initialise SD card - check connections" );
errorState();
}
After soldering some wires to check the SPI lines with a logic analyser, it appears the MOSI, SS, and CLK lines are working correctly, but MISO always stays high (never responds to the request sent through MOSI)
The only time I saw MISO going low is during flashing or power-up.
I also did a continuity test from each solder pad of the SD card reader/slot to the corresponding pin. I was expecting roughly 0 - 1 ohm but was surprised to see each pin had a resistance of 30 ohms to the respective solder pad. Is this normal?
I am not sure what is going on, any insight would be appreciated.