Go Down

Topic: Arduino Mega 2560 with Ethernet Shield with PoE (Read 1 time) previous topic - next topic

paddi

Hello.

I'm using the Ethernet Shield with PoE (A000075) with the Arduino Mega 2560 Rev03 (A000067) with the arduino 1.0 IDE. The shield fits exactly to the board, but I can't connect to the server neither to the sd card. The shield works fine with an Uno.
I've already read the topics for rewirering the ICSP-Pins from 10-13 to 50-53, but I also found in the SD2PinMap.h which is included within the compilation of the files with th sd library.
Almost at the beginning, there is a defined part for the AVR_MEGA_2560, in which the correct pins are chosen:
// SPI port
uint8_t const SS_PIN = 53;
uint8_t const MOSI_PIN = 51;
uint8_t const MISO_PIN = 50;
uint8_t const SCK_PIN = 52;

At the end for default:
// SPI port
uint8_t const SS_PIN = 10;
uint8_t const MOSI_PIN = 11;
uint8_t const MISO_PIN = 12;
uint8_t const SCK_PIN = 13;

How can I use the already defined section to properly use of the sd card slot?

THX
Paddi


SurferTim

You don't need to rewire anything for those new devices. The SPI data lines are on the ICSP connector. Digital pins 11-13 are not connected to anything on the shield.

Digital pin 10 is the w5100 SS pin, and digital pin 4 is the SD SS pin.

paddi

I know that fact,
but the sd card don't work with the mega, but with the uno. When I upload the data to the uno, the terminal comes ith the correct answers.
When I replug the shield to the mega and upload the data to the mega, the initialization fails always.

I've read sometimes that I have to change the wirering to the ICSP.
But I haven't found anything for the IDE 1.0


SurferTim

I have a Mega and an ethernet shield. I use the SD card also, and it works. Have you tried disabling the w5100 SPI before initializing the SD card? That is where it is failing for you, correct?

Code: [Select]
void setup()
{
  Serial.begin(9600);

  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);

  // you are failing here?
  if(SD.begin(4) == 0)
  {
     Serial.println("SD fail");
  }
   else
   {
      Serial.println("SD ok");
   }

  Ethernet.begin(mac,ip);
  digitalWrite(10,HIGH);

  // rest of the setup
}



paddi

Yes, I think so.

Where can I change / disable the w5100?
I've used the sd examples for general testing the new ethernet shield.

THX
paddi

SurferTim

It is in the code above. That is why I posted it for you.  :)

This disables the w5100 SPI so it will not interfere with the SD.begin(4) function.
Code: [Select]
   pinMode(10,OUTPUT);
   digitalWrite(10,HIGH);


paddi

#6
Mar 18, 2012, 09:46 pm Last Edit: Mar 18, 2012, 09:49 pm by paddi Reason: 1
Sorry for silly answer.

I haven't seen the difference directly.

Many thanks, works fine.

Question:
In this way, the digital pin 10 is not more working, that's right?
And why is the digital output connected with the chip lane 5x?
And does it have any cross connections with the ethernet controller chip?

SurferTim

When you disable the w5100 SPI, it is only temporary. That allows the SD SPI to initialize the SD card.

The SD.begin(4) function returns with its SPI disabled (pin 4 HIGH), so nothing needs to be done on the function return.

The Ethernet.begin(mac,ip) function will activate its SPI to set up the w5100, and then returns with its SPI enabled (pin 10 LOW), so you need to set digital pin 10 HIGH again after the Ethernet.begin() function.

At this point, the low level read/write functions of each library control these SS pins, so it is not necessary for you to do it.



Go Up