SD + Ethernet

Hello!

I was new in the arduino world i bought a mega 2560 with microsdcard module and one ethernet module.
I want to use the 2 module at same time. I saw here i need to play with the SPI ports but i don't really understand it.

If i connect the two module and i setup an ethercard webclient example the ethernet won't work but if i remove the VCC from the sd module the ethernet works fine.

Someone have idea?

You must disable the SD SPI before initializing the ethernet module. If you are using D4 for the SD SPI SS, then...

pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
// then start the the ethernet module here

Thanks.
Here is my test code: #include <SPI.h>#include <SD.h>#include <EtherCard.h>static byte mymac[] - Pastebin.com
There isn't any code for sd only the the first two inc but it dosen't matter cuz if i remove the problem same.
In this setup if the sd module connected i get "Failed to access Ethernet controller" if i remove the vcc from the sd i can.

I use the 50,51,52 for both module and the 4 for the sd and the 10 for the ethernet. GND the digit GND and the power is 5v for sd 3,3v for ethernet.

Which SD module are you using? Does it work ok by itself?

Catalex microsd card adapter and yes it works fine by itself.

I use this modules:
SD: http://www.ebay.com/itm/171490520352?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
Ethernet: http://www.ebay.com/itm/111855815497?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

It should work ok with that ethernet module. Connect the power to the SD module, but disconnect the MISO line from the SD module to the Arduino. Does the ethernet module work ok then?

Yes, if i remove the miso the ethernet works.

Have you tried another SD card? Maybe that particular card has failed.

The card and the reader works fine. There is a problem maybe with the cs. With only the ethernet if i set the pin 10 to high (disable) it works too. So i can't disable it. In this type i can't disable the sd too. Se there is some mistake maybe i connected to wrong ports or i don't know.

If the SD card does not release the MISO line when the SD CS is HIGH, the scenario you describe is the result. The SD card will work if the MISO line is not released (hi-z).

You can test this. Connect only the SD module, then insert a 1K resistor from the SD MISO line to an adjacent pin, like D9. Set that pin as OUTPUT. Pull the SD CS line HIGH. Alternately set the adjacent pin to HIGH and LOW. The SD MISO side of the resistor should change with the adjacent pin. If it doesn't, the MISO line is not being released by the SD card.

The SD works fine. The module and the card both.

SpeAroX:
The SD works fine. The module and the card both.

Did you test the MISO line? The SD card will work if it is not releasing that line, but no other device will work with it. Did you try another SD card?

If you want to test the SD card:
To be safe, use a 1k resistor connected to a ground pin and another 1K resistor connected to the 3.3v pin. Connect the SD module using only ground, power (5 volts), and the CS pin to 3.3 volts (HIGH should disable the MISO line).

Alternately connect the MISO line from the SD module to each of those two resistors. Use a voltmeter (or an analog pin on the Arduino) to check the voltage on the module's MISO line. The MISO line on the SD module should show the same voltage as the resistor. Near 0 when ground, and near 3.3 volts when 3.3 volts.

GND ----////----o < test connection for GND (LOW)
3.3v ----////----o < test connection for 3.3 volts (HIGH)

If i don't connect the miso line to the board and i check it if the digitalWrite(SS_SD_CARD, LOW); then i got 3,3 if HIGH i got 0. But it i set to HIGH and connect both card the problem still here.

The MISO line on the SD card may be stuck at 0 with the SD SPI disabled. If that is the case, the ethernet will not work. Did you try the test above? If not, I am wasting my time here.

edit: If the SD MISO line is not going to a high impedance state (hi-z), you will get the fails you are experiencing. The test above verifies the SD card is releasing the MISO line.

After SD begin the miso stay in 3,3. Dosen't matter if i put digitalWrite(SS_SD_CARD, HIGH); or digitalWrite(SS_SD_CARD, LOW);

I presume you mean it stays at 3.3 volts even if you try to pull it to ground with the resistor. If that is the case, that is your problem. The SD card has partially failed and is not releasing the MISO line. It could be the SD module not setting the SD card slave select HIGH. The logic level converter fail would cause that.

Yes i mean this. I tryed to replace the sd i tired 3 card and i replaced the module too. Same problem. Maybe the default librari?

Not the library. If the MISO line is not releasing, there are only two reasons I can think of.

  1. SD card malfunction.
  2. Slave select line to SD not going HIGH. Could be logic level converter fail.

You have replaced the SD card more than once it sounds like, and the chances of that happening with more than one card is slim to none. That leaves option 2. The only thing I can suggest at this point is to do a Google search for "micro SD pinout", and check the voltage from ground pin to the slave select (CS) pin on the SD socket while the input slave select is HIGH. It should be HIGH. If not, it is the logic level converter on the module.