how to use sd slot with atmega 328?

I am trying to use the sd slot withe atmega 328 in pcb, but i’m getting proglem while connecting the pins. how should i connect he mosi, miso and sck pins of the sd slot with the microcontroller pins? when i connect same slot in arduino it works fine. i didn’t get what is this connect low impedence to icsp pins which i saw in atm.ega datasheet. how can i do it?

What voltage are you running the 328? If it's over 3.3V then you need level converters. The SD card uses an SPI interface so you only need unidirectional level converters, not bidirectional like I2C.

A voltage divider can work to get the 5V microcontroller outputs down to 3.3V for the card. Then the MISO line can be wired direct - just don't use a pullup on that pin. 3.3V from the SD card will appear as a logic HIGH to a 5V system.

If there's a web page or forum post you don't "get" then please give us the link so we can check it out and help with the translation.

I don't know how much of a concern this is but I did notice this in the SdFat library documentation:

The hardware interface to the SD card should not use a resistor based level shifter. SdFat sets the SPI bus frequency to 8 MHz which results in signal rise times that are too slow for the edge detectors in many newer SD card controllers when resistor voltage dividers are used.

The 5 to 3.3 V level shifter for 5 V Arduinos should be IC based like the 74HC4050N based circuit shown in the file SdLevel.png. The Adafruit Wave Shield uses a 74AHC125N. Gravitech sells SD and MicroSD Card Adapters based on the 74LCX245.

If you are using a resistor based level shifter and are having problems try setting the SPI bus frequency to 4 MHz.

i followed this tutorial to make the arduino in breadboard, but don't know how to use the sd slot with it. Arduino - Setting up an Arduino on a breadboard

Have you tried connecting it to your breadboard Arduino just the same as you did with the regular Arduino when it worked?

Yes i did, but it didn't worked. should i connect some extra resistor or something?

Are you using an SD socket:

an SD module:

or an SD shield:


If you are running your Atmega328p at 3.3 volts, and you have your fuses set correctly, you will not need a voltage level translator between the microcontroller and SD card.

If they're following the Arduino breadboard tutorial at the link they posted above then they're running at 5 V, it specifies a 7805 voltage regulator.

i am using sd module as u've posted above. exatly same. so now what should i do and how?

Post a picture that clearly shows how you have the SD module connected to the microcontroller on the breadboard. Follow these instructions to attach and embed the image:

i am using sd module as u've posted above. exatly same. so now what should i do and how?

This one is identical with the pins labeled:

and a connection diagram

You can put the chip select pin on any pin you like, including D10 which is the typical slave select pin in the Atmega, but a lot of the code examples use D4 because that's where the Ethernet Shield puts it.

Ok, thanks the last answer solved my problem. i was connecting the mosi, miso ans sci pins according to the arduino pins initially but after following the diagram given above, it is working. hurray. thank u.