Go Down

Topic: Issue interfacing SD card to Atmega32U4 (Read 433 times) previous topic - next topic


Jan 17, 2019, 09:44 pm Last Edit: Jan 18, 2019, 10:22 am by MerryXmas
So I posted this in the General Electronics section before...but I just realised this sub-forum exists:

I am running into some issues interfacing an SD card reader with the ATmega32U4. The SD card does not initialise. At this stage I am suspecting it's a hardware related issue.

This project involves a PCB and doesn't use the Arduino type SD card breakout.

In the microcontroller schematic I have ticked in red marker the connections from the microcontroller to the SD card aspect.

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.

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:

What have I done wrong? Code for initialising the SD card is as below:
I am using the SD.h library

Code: [Select]
  if ( SD.begin(  ) )
    Serial.println( "SD card initialised" );
    Serial.println( "Unable to initialise SD card - check connections" );

Further checks:

Level shifted MOSI is 3.3V
Level shifted Chip Select goes to 3.3V when it tries to initialise and then back to 0V
Level shifted SCK goes to about 2.2V and then drops back to 0V
MISO sits either at around 0.6V or 0V, randomly changes.


You are connecting the SD module directly to the ATmega32U4 chip? If you are doing this i can't help you, cause i m so newby for this.

I just make it run whit my arduino mega board

Go Up