Go Down

Topic: Mighty 1284p SPI / Ethernet how to get it work ? (Read 3 times) previous topic - next topic

Nick Gammon

Well there is good news and bad news.

The good news is, I've reproduced your problem. :)

The bad news is, the fix is not totally working. :(

I hooked up my 1284P to my Ethernet Shield Rev 3, and found that (using the logic analyzer) although the signals were going out as expected, nothing was coming back.

Then I took a closer look and realized that the shield is designed to interface with the ICSP header (underneath) rather than pins 10/11/12/13 because it is designed to be plugged into other boards, like the Mega.

So I moved SCK, MISO, MOSI to the ICSP header.

Code: [Select]

       Atmega1284P    Ethernet Shield

SS     pin 5  (D4)      D10 on the shield
MOSI   pin 6  (D5)        ICSP pin 4
MISO   pin 7  (D6)        ICSP pin 1
SCK    pin 8  (D7)        ICSP pin 3

Now at least it got a response. But still rather flaky. It didn't hang on the connection any more. Just "failed".

I made the change I mentioned to the w5100.h file. I experimented with slowing down SPI:

Code: [Select]

  // start the Ethernet connection:
  Ethernet.begin(mac, ip);
  SPI.setClockDivider(SPI_CLOCK_DIV16);   // slow down SPI

It connected a couple of times, it got data back a couple of times. You may have more luck with your wiring. I think I have a lot of noise here, I am having trouble uploading the sketch.

This should get you closer.

Nick Gammon

Further to the above, it appears that during testing I crashed the server I was connecting to. So it might be more reliable if you implement all those changes. Maybe. :)


Was any solution to this ever found? I'm experiencing the same with 1284P. I tried both Calunium and Mighty1284 with the same result: a hanging 1284P when I call ethernet.begin(...)


I found that the issue only exists when attempting to use DHCP.


I just got back from summer hollidays, sorry for not giving back any infos soon after Nick sent his message about a fix. I did not had time to tried.
Really, only DHCP does that ? i tried both fixed IP and DHCP and the result was the same. IIRC last month test.

I found that the issue only exists when attempting to use DHCP.


Aug 09, 2012, 02:26 am Last Edit: Aug 09, 2012, 02:30 am by pito Reason: 1
Do you have enough power to run the ethernet chip ? - I've seen somewhere it takes up to 180mAps of current while operating (crash at eth.begin??) - check your power generators first.. :)


Aug 09, 2012, 08:24 am Last Edit: Aug 09, 2012, 08:29 am by kfuglsang Reason: 1
Power should be fine; I had the same circuitry for a 328P-based setup where the same ethernet (wiz820io) module was working fine.

When using a static IP, the atmega does not freeze and I can ping the device from my local PC. The hanging only occurs when calling ethernet.begin() to fetch an IP address from the local DHCP server.

I'm on Arduino 1.0.1 btw.


I spent some more time on it this morning.

I created a small LAN, straight between my laptop (acting as a DHCP server) and the Wiz820io module. I found that the atmega does in fact not hang; it just never receives a DHCP response.

Using WireShark I found that the laptop never receives a DHCP request. I added some Serial.print()'s in the DHCP.cpp code to verify that send_DHCP_MESSAGE() is called and executed.

The Atmega continues within the parseDHCPResponse() function and loops continously within the loop:
Code: [Select]
while (_dhcpUdpSocket.parsePacket <= 0) { ... }
until the responseTimeout is exceeded. After this, the process happens again, still with no DHCP request sent across the wire.


Aug 09, 2012, 02:02 pm Last Edit: Aug 09, 2012, 03:13 pm by kfuglsang Reason: 1
Further debugging reveals that using a static IP  I can:
- ping the Atmega from my laptop
- send UDP packet to my laptop (using my laptop's specific IP)
- send UDP broadcast packet and receive it on the laptop

All verified using Wireshark.

Nothing is transferred when I try to use DHCP. My laptop has a DHCP server running, verified working using another PC.

EDIT: Further debugging. Finally saw DHCP requests coming to the PC. Unfortunately, it seems very shaky and I never had it complete the DHCP negotiation.

EDIT2: After letting it run for an extended period I saw it connect a few times and start to send some UDP packets (I added that in the loop() function). Each time when it has connected, it rebooted after 10-15 seconds.
Could it be an issue with my power supply, noise or something else?


This morning I tried to use a static IP and let it send an UDP broadcast for every second, while also outputting the IP address of the W5200 module.

I noticed that all of a sudden, perhaps after 10-20 seconds, the IP address starts to change sporadically and packets are no longer being transferred. After this, I need to restart the Arduino to get it working again.

I verified my power supply as well. 5.1v being supplied to the atmega1284p (data sheet specifies 4.5-5.5v for 16MHz operation) and 3.28v going to the Wiz820io.



What type of voltage regulator for 3.3V do you use?


Aug 10, 2012, 12:39 pm Last Edit: Aug 10, 2012, 12:42 pm by kfuglsang Reason: 1
It's a LM1117-3.3.

Go Up