USBasp MISO line interference?

Hi, I have a standalone atmega328 which I program using a USBasp (MISO, MOSI, SCK, Vcc, GND, /RST)

I also have a SD Card Reader attached to the MISO, MOSI, SCK, CS lines - following this diagram (not with an Arduino though, it is just the MCU):

The SD Card reader works fine, I can read and write files etc.

The problems is that in order to use the USBasp, I first have to either

  1. disconnect the power completely to the SD Card reader, OR
  2. disconnect the MISO line from the SD Card reader (that is shared by the USBasp and the SD Card reader)

So it seems that the MISO line is not sharing.

avrdude gives the error that the target isn’t responding or i have seen it say that the device signature is incorrect.

I have tried using pull-up resistors on the MISO, MOSI, SCK, and CS lines. Does not make a difference.

Any tips?

Thanks very much

output:

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is “C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf”

Using Port : usb
Using Programmer : usbasp
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : usbasp
Description : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x0001ff
avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.

avrdude done. Thank you.

The MISO line is often not sharing. That's a major problem when adding multiple shields or combining hardware. Another problem is mixing 3.3V SPI signals with 5V SPI signals.

Can you give schematics and photo of your project ? And a link to the SD module ?
If the SD module is 3.3V, and your USBasp is 5V, then the MISO of the USBasp could be lowered by the SD module. That means that even if the sharing is okay, it still might not work.

rj77:
I also have a SD Card Reader attached to the MISO, MOSI, SCK, CS lines...

Does it have an external pullup on Chip Select?

Yes it does - I have attached an LED to that to monitor it - when the programmer starts, it is pulled low briefly.

Koepel:
The MISO line is often not sharing. That's a major problem when adding multiple shields or combining hardware. Another problem is mixing 3.3V SPI signals with 5V SPI signals.

Can you give schematics and photo of your project ? And a link to the SD module ?
If the SD module is 3.3V, and your USBasp is 5V, then the MISO of the USBasp could be lowered by the SD module. That means that even if the sharing is okay, it still might not work.

Everything is 5V (USBasp and SD Card Reader).

The SD is a catalex brand.

While googling for it, I just noticed this:

https://www.reddit.com/r/it.arduino/comments/2vkp81/fyi_catalex_microsd_card_adapter_does_not_play/

It says:

I eventually determined that the Catalex module seems to hold the MISO line hostage, regardless if it is initialized or not. I tried setting the CS pin for the module HIGH, which should make the module ignore the SPI bus. I even tried disconnecting the CS pin and jumpering it straight to 5V to no avail. The only solution was to put a jumper inline with the MISO pin to physically disconnect it, and jumper the CS pin to HIGH when I want to disable

A reply to this:

I had the same problem with an RFID-RC522 card which wouldn't work when the Catalex module was connected. I put a 2K2Ω resistor between MISO on the MicroSD card and MISO (Pin 12) on the Arduino (pro mini) and it is working fine now.

So I tried that but it didn't fix it in my circumstances. The programmer would work, but the SD was no longer functional.

I have decoupling capacitors across Vcc and GND.

I have got it to work in the past, but I can't recall under what circumstances. :frowning:

More googling reveals that this catalex brand sd card reader is to be avoided because it holds the MISO line hostage.

I think i have found how I did it the past: set the usbasp to 3.3V. It works, and then when 5V is reinstated, the sd card reader works.

Thanks for the help

Thank you for the follow-up.

rj77:
I had the same problem with an RFID-RC522 card which wouldn't work when the Catalex module was connected. I put a 2K2Ω resistor between MISO on the MicroSD card and MISO (Pin 12) on the Arduino (pro mini) and it is working fine now.

Dear rj77,
Thanks for your post. I have had the same problem and solved it with a resistor between Arduino MISO pin to SD card MISO pin as your recommendation. But I think 2.2K is not enough to feed SD card MISO, so that the correct value of this resistor is 220 Ohm for me. Then Both USBasp and SD Card Reader work for me with no problem with this solution.
Thanks.

For the record, emrekara's advice worked well for me.

Adding 330 Ohm resister on the MISO line between the SD Card reader and all the other components on SPI solved this problem.

Thank you, too bad it took so many hours to find this thread :slight_smile:

Thank you very much for this info.
my usbtiny programmer was giving me the blues.
but this is the exact fix i needed.
i also used a 220 ohm resistor on the miso line of the catalex sdcard shield and Viola!
love this community!!!

220 ohms worked for me...I spent many hours to solve the issue and thanks