SD Card Reader - controlled by standalone atmega328p vs Arduino Nano

Hi Experts,

I have an SD Card Reader (5V) that I have confirmed works fine with my Arduino Nano.

Is there any reason why if I hook it up in exactly the same way to a standalone atmega328p that it wouldn't behave?

I am connecting the Card Reader -> Atmega:
CS -> Pin 16 ("SS")
MISO -> Pin 17 ("MOSI")
MOSI -> Pin 18 ("MISO")
SCK -> Pin 19 ("SCK")

I am finding that it can't initialize using the RTClib as it did happily before when controlled by the Arduino.

A secondary question I have is that when I program the Atmega328p using a USBasp, I have to disconnect the MISO from the SDCardReader otherwise the flashing procedure fails. Should they be able to share the line?

Thanks for any help

rj87:
Hi Experts,

I have an SD Card Reader (5V) that I have confirmed works fine with my Arduino Nano.

Is there any reason why if I hook it up in exactly the same way to a standalone atmega328p that it wouldn't behave?

A secondary question I have is that when I program the Atmega328p using a USBasp, I have to disconnect the MISO from the SDCardReader otherwise the flashing procedure fails. Should they be able to share the line?

No, they should be the same. Did you include decoupling caps? Did you include proper caps on your regulator?

They should be able to share the line as long as the CS line for the SD card is held high. Which it isn't, because the chip is in reset state and the pin is floating, so the SD card is active at least some of the time, and putting crap onto MISO. Put a pullup resistor on CS line for SD card so it's high when the chip is tristated.

DrAzzy:
No, they should be the same. Did you include decoupling caps? Did you include proper caps on your regulator?

They should be able to share the line as long as the CS line for the SD card is held high. Which it isn't, because the chip is in reset state and the pin is floating, so the SD card is active at least some of the time, and putting crap onto MISO. Put a pullup resistor on CS line for SD card so it's high when the chip is tristated.

Thanks very much for your reply.

  1. I have added decoupling caps and my regulator was already good. Still a problem with the SDCardReader. I might try rewiring from scratch.

  2. I have added a 10k pullup resistor at the SDCardReader but it still won't let me program - I get:

"avrdude: initialization failed, rc=-1"

until I pull out the MOSI on the atmega -> MISO on the card reader line.

Thanks very much for your help

rj87:
MISO -> Pin 17 ("MOSI")
MOSI -> Pin 18 ("MISO")

These should be
MISO -> MISO
MOSI -> MOSI

oqibidipo:
These should be
MISO -> MISO
MOSI -> MOSI

Arrgh that worked! Thank you very much! I have done a few searches and it seems that with other people's circuits it's half and half MISO->MISO and MISO->MOSI... so confusing.

However I am still stuck with the problem of not being able to program using the USBAsp while the SDCardReader is connected.

I have put pullup resistors onto MOSI and MISO but no luck.

What should the other pins be tied to?

Thanks for any assistance...