W5500 board fails on Mega 2560

I’ve spent the last 3 days trying to get a W5500 Ethernet Shield to work on a Mega 2560 and got nowhere.
I started a thread on the Arduino forum asking for help and got a good number of replies but am still unable to get the board to work.

Rather than copy paste everything from the Arduino forum into this post i ask that you have a read of my thread.

Two different W5500 Ethernet Shields fail 100% on three different Mega 2560s but the shields work fine on a Uno.

Where can i look for help next?
Thanks.

Can you attach the ethernet shield image and code and settings?

Hi.

You must be used Ethernet2 library of Arduino.
It doesn’t work Ethernet library. it is W5100 target library.
refer to below link.

Maybe 1.8.0 Arduino IDE version is not installed Ethernet2 library.
So, you have to install Ethernet2 library.
path is (Enter to Arduino IDE → Sketch → library manage)
You should be install to 1.0.3 ethernet2 library.

Thank you

Thanks for the replies.

First let me say that i think the problem is related to SPI and not the ethernet library being used.
Let me explain…

I have installed the Ethernet2 library and tried this example sketch:

The sketch works with my W5500 Ethernet Shield on a Uno but fails on two different Mega 2560s.
On the Mega 2560s the sketch always hangs at:

Ethernet.begin(mac)

I’ve left the sketch running for many minutes many times but the call to Ethernet.begin always fails to return.

Now i also have the SdFat library installed and am trying this example sketch:

The sketch works fine on a Uno but again fails on both my Mega 2560s.
It logs an error code 0x20, which i can’t find any reference to in order to understand the error.

On both example sketches i have added some additional code to set the Mega slave select pin as an output:

//  set mega 2560 SS pin to output mode
pinMode(SS, OUTPUT);

The Sdfat example sketch contains code which can be used to disable any secondary SPI device attached:

/*
 * Set DISABLE_CHIP_SELECT to disable a second SPI device.
 * For example, with the Ethernet shield, set DISABLE_CHIP_SELECT
 * to 10 to disable the Ethernet controller.
 */
const int8_t DISABLE_CHIP_SELECT = -1;

So i changed -1 to 10 in order to disable the ethernet controller while running the SdFat example.

Now is the problem a hardware fault with both of my Mega 2560s?
I think not - a colleague has also tried another W5500 Ethernet Shield on his Mega 2560 with the same failure.
Note also that all three Mega 2560s work fine with a Arduino Ethernet Shield 2.
Other SPI devices work fine on all three Mega 2560s.

Is the problem a hardware fault of the W5500 Ethernet Shield?
I think not - we have two shields and both fail on Mega 2560s but work on a Uno.

I’ve attached my modified version of the Ethernet2 DhcpAddressPrinter.ino sketch.
DhcpAddressPrinter.ino.hex (1.3 KB)
Rename DhcpAddressPrinter.ino.hex to DhcpAddressPrinter.ino, the forum wouldn’t let me upload a .ino type file.

I’ve made some progress and the ethernet part of the shield is now working.
I simply jumpered the shield ICSP pins to the Mega ICSP pins and then jumpered pin 10 from shield to Mega.
(I thought i’d done exactly this previously but am not sure).
So ethernet works.

I then jumpered pin 4 from shield to Mega.
Ethernet still works - with and without an sdcard inserted into the shield.

However all sketches fail to access the sdcard part of the shield, they still fail as before with the SdFat example showing error code 0x20.
The sdcard sketches i have tried all set the Mega SS pin to OUTPUT mode HIGH and ethernet CS pin 10 to OUTPUT mode HIGH.

I shall experiment more but if anyone has any suggestions i’d be glad to read them.

Did Wiznet ever fix that buggy implementation of SPI in the W5000 chip or is that still a problem with the W5500 chip?