Ethernet.begin hangs after power cyle in Nov 29, 2016 release

Status
Not open for further replies.

bigDan

Member
Hi,

This is my first post. Been using Teensies for several years, love them, and I've been able to track down every question/problem via google in the past.

I am upgrading a complex project to the new Wiz850io. I have the latest ethernet library found in Github, dated Nov 29, 2016. At the moment, I'm still using a Wiz820io (I'm going to need to support old 820's and new 850's going forward).

If I use the latest code on the Wiz820io, Ethernet.begin will hang after cycling power. Let me further explain the scenario:

. I can compile/execute on old library code fine.
. I can compile/execute on the new library code fine.
. I power cycle the Teensy (which now has the new library code).
. Ethernet.begin now hangs.

If I recompile using the old library code, everything functions fine again.

The code to reproduce the problem:

Code:
#include <Arduino.h>
#include "Ethernet/Ethernet.h"
//#include <Ethernet.h>

EthernetClient      eClient;

void setup(
    ) {

byte                mac[] = {0x04, 0xE9, 0xE5, 0x01, 0xF8, 0x86};

Serial.begin(9600);

while (!Serial.dtr()) {}

Serial.println("e.begin");

if (Ethernet.begin(mac) == 0) {
    Serial.println("begin failed");
    while (true) {}
    }

Serial.println("e.begin passed");

} // setup

void loop(
    ) {

} // loop

In this example, the new library is in "Ethernet/Ethernet.h" while the old code is in the default location.

Further, if I go back to stable111 branch, this problem isn't occurring.

Any help would be greatly appreciated!

Dan
 
Look here and scroll down to "Chip Select Pins During Initialization". I think you should include that code at the top of your setup() function.

I'm guessing that the WIZ820io IS NOT resetting properly when you power-cycle it, whereas it IS when power has been off for a longer time.
 
Last edited:
Unfortunately, that made no difference.

BTW, I am not using the SD card, just a straight Wiz820io.

I've got just shy of 10 units that have been running on Wiz820's with the older library, some for a year now w/o problem. I've replicated the hang problem on two of those by just upgrading to the new ethernet library.

I also neglected to mention this is a Teensy 3.2

One other thing I forgot to mention, when I cycle power, they physical layer never comes up - there are no LEDs lit on the Wiz820io or the switch.

As the code stands now:
Code:
#include <Arduino.h>
#include "Ethernet/Ethernet.h"
//#include <Ethernet.h>

EthernetClient      eClient;

void setup(
    ) {

byte                mac[] = {0x04, 0xE9, 0xE5, 0x01, 0xF8, 0x86};

pinMode(9, OUTPUT);
digitalWrite(9, LOW);   // reset the WIZ820io
pinMode(10, OUTPUT);
digitalWrite(10, HIGH);  // de-select WIZ820io
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);   // de-select the SD Card

Serial.begin(9600);

while (!Serial.dtr()) {}

Serial.println("e.begin");

if (Ethernet.begin(mac) == 0) {
    Serial.println("begin failed");
    while (true) {}
    }

Serial.println("e.begin passed");

} // setup

void loop(
    ) {

} // loop

Dan
 
Last edited:
Please detail your wiring. Are you using the PJRC breakout board?

Try adding
Code:
digitalWrite(9, HIGH);
after
Code:
digitalWrite(4, HIGH);   // de-select the SD Card

Make sure you use the latest Ethernet lib included in Teensyduino. This supports the Wiz850io and is hugely optimised compared to the Arduino Ethernet lib.
 
In this example, the new library is in "Ethernet/Ethernet.h" while the old code is in the default location.

More than 1 copy present is almost certain to cause problems. The overall layout of the Ethernet library files have changes too. A utility folder is no longer used.

Please backup ALL copies to a place Arduino doesn't search, and then try with clean copy Arduino 1.8.1 and Teensyduino 1.35, using the default #include <Ethernet.h>. I have personally tested the Ethernet lib in 1.35 on both WIZ820io and WIZ850io. It does work.
 
Hi Dan,

I had a very similar problem to you - powering up for the first time; everything ok. Power cycle (or in my case, downloading a new firmware) = problems.

Just as a quick check, try running this before Ethernet.begin(...)
pinMode(9, OUTPUT);
digitalWrite(9, LOW); // reset the WIZ820io
delay(1000);
digitalWrite(9, HIGH); // release the WIZ820io
 
First, I installed the latest arduino/teensyduino and made sure the only place it would locate Ethernet code was from the arduino directory.

I really expected that to fix it as no one else seems to be having issue with something so simple. But it didn't. Ethernet.begin() still hangs.

I then toggled pin 9 as suggested by macaba. That worked!

To verify toggling the pin was the solution, I returned back to Arduino 1.6.7/Teensyduino 1.27 with the master Ethernet library from github (all of the original libraries when the problem started).

I applied the toggle solution using those libraries and it works fine.

Finally, to be 100% sure this was the solution, I removed the toggle code and again the Teensy hangs in ethernet.begin if power is removed.

This appears to be the solution even though prior libraries never required it, at least not for my code.

Enclosed is a schematic of my teensy/wiz820io wiring. The only thing I've questioned lately is why the PWDN signal is not connected, though I assume at the time I did that on purpose.

teensyHang.png

Dan
 
Ah yes, the older versions toggled pin 9. That was removed in the new version, since it hogs pin 9 without any way to reconfigure to other pins.

The W5200 chip absolutely needs a reset pulse. The adaptor board has a CAT811 chip that gives it a pulse at startup.
 
I've added this to the WIZ820 page. Hopefully it will help.

WIZ820io requires a reset pulse to function properly. WIZ850io is more tolerant of startup without reset, but a pulse on the reset pin is absolutely required for the older WIZ820io modules.

This adaptor has a CAT811T reset chip to automatically pulse reset at powerup. However, after uploading a new program, your WIZ820io may be left in a prior state depending on where your prior program stopped. Pin 9 should be used to manually trigger the reset pulse for best compatibility with WIZ820io and W5200 chips. See the initialization code below for an example.
 
Ah, OK. I don't have the adapter board.

I've got the latest/greatest libraries and the reset pulse in the production code and it is working perfect.

One last question. Per the example, I placed the reset pulse in the setup code; however, my device never resets (setup would only be called on a power cycle and those are expected to be very infrequent). If network issues are detected, Ethernet.begin is called repeatedly until the network finally comes back up.

Should I place the reset pulse prior to the Ethernet.begin so it always occurs right before initializing the network? It doesn't seem like there is any penalty for doing so.

Dan
 
Yes, do the reset pulse right before you call Ethernet.begin().

This got me thinking, so I looked it up:

From WIZ820io User Manual, 4.1 Reset Timing

Minimum nRST width is 2 us.

Maximum delay until PLOCK (Internal) - whatever that is - 150 ms.

So, the reset pulse should be at least 2 us and it might take the WIZ820io up to 150 ms to come out of reset. Am I correct in thinking that delays are needed to ensure that these are met?
 
Last edited:
I then toggled pin 9 as suggested by macaba. That worked!

That's good to hear - you will probably find that 1000ms delay is far more than needed, a very small delay should work.

Paul - I've got some older adapter boards that don't have the reset IC (as well as my own PCBs) and now they require the additional reset pulse code - it's probably going to be a reoccurring support issue on the forum from now on hence why I've responded to about 3-4 threads related to W5200. I'm just wondering if it might be easier to just put the reset pulse back into the library?
 
Last edited:
Status
Not open for further replies.
Back
Top