Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 40

Thread: W5100 Ethernet shield preventing Teensy 3.2 from reprogramming

  1. #1
    Junior Member
    Join Date
    Feb 2016
    Posts
    15

    W5100 Ethernet shield preventing Teensy 3.2 from reprogramming

    HARDWARE:
    I've started work on a Teensy3-based project that interfaces with a W5100 Ethernet Shield by using a Teensy Arduino Shield Adapter. The crystal (DigiKey 300-1002-ND) was soldered to the Teensy, the adapter board was properly assembled, and I've soldered the Teensy+crystal to the adapter. When I stack the Ethernet board atop and run the following code, adapted from the TimeNTP example, the network lights are active, but the Teensy/adapter no longer responds to reprogramming/reboot requests nor does the COM port show up for any IDE (Arduino, UECIDE, etc) or serial terminal program. My current issues are twofold:

    1) Does anyone have any ideas about best next steps to take to enable programming the Teensy while its stacked with the Ethernet shield?
    2) Also, although the crystal is installed and the button battery is attached and charged, the Teensy does not seem to be keeping time when unplugged...

    SOFTWARE:
    Note: The Teensy/adapter without Ethernet Shield works properly for Serial time update examples.

    Code:
    /*
     * Time_NTP.pde
     * Example showing time sync to NTP time source
     *
     * This sketch uses the Ethernet library
     */
     
    #include <TimeLib.h> 
    #include <Ethernet.h>
    #include <SPI.h>
    
    int eflag=0;
    int leddelay=1000;
    int led=13;
    
    byte mac[] = { 0x04, 0xE9, 0xE5, 0x02, 0x57, 0x3A }; 
    // NTP Servers:
    IPAddress timeServer(132, 163, 4, 101); // time-a.timefreq.bldrdoc.gov
    // IPAddress timeServer(132, 163, 4, 102); // time-b.timefreq.bldrdoc.gov
    // IPAddress timeServer(132, 163, 4, 103); // time-c.timefreq.bldrdoc.gov
    
    // Client IP address
    IPAddress ip(192, 168, 0, 150);
    
    //const int timeZone = 1;     // Central European Time
    const int timeZone = -5;  // Eastern Standard Time (USA)
    //const int timeZone = -4;  // Eastern Daylight Time (USA)
    //const int timeZone = -8;  // Pacific Standard Time (USA)
    //const int timeZone = -7;  // Pacific Daylight Time (USA)
    
    
    EthernetUDP Udp;
    unsigned int localPort = 8888;  // local port to listen for UDP packets
    
    void setup() 
    {
      pinMode(4, INPUT_PULLUP);   // Tried this gem which was recommended somewhere else on the forum
      pinMode(10, INPUT_PULLUP); // since this sketch is not (currently) making use of the SD card
      
      Serial.begin(9600);
    
      delay(250);
      Serial.println("TimeNTP Example");
    
      if (Ethernet.begin(mac) == 0)  Ethernet.begin(mac, ip);
      Serial.println("[46]: Ethernet information set.");
      
      Serial.print("[48]: IP address assigned is ");
      Serial.println(Ethernet.localIP());
      Udp.begin(localPort);
      Serial.println("[51]: waiting for sync");
      setSyncProvider(getNtpTime);
    
      pinMode(led, OUTPUT);
    }
    
    time_t prevDisplay = 0; // when the digital clock was displayed
    
    void loop()
    {
      if (timeStatus() != timeNotSet) {
        if (now() != prevDisplay) { //update the display only if time has changed
          prevDisplay = now();
          digitalClockDisplay();  
        }
      }
    }
    
    void digitalClockDisplay(){
      // digital clock display of the time
      // modified by ZurielSeven to show 
      // the timestamp in MySQL DATETIME format
      // this will come in handy in the cloud!!
    
      Serial.print(year()); 
      Serial.print("-");
      if (month()<10) Serial.print("0");
      Serial.print(month());
      Serial.print("-");
      if (day()<10) Serial.print("0");
      Serial.print(day());
      Serial.print(" ");
      Serial.print(hour());
      printDigits(minute());
      printDigits(second());
      Serial.println(); 
    }
    
    void printDigits(int digits){
      // utility for digital clock display: prints preceding colon and leading 0
      Serial.print(":");
      if(digits < 10)
        Serial.print('0');
      Serial.print(digits);
    }
    
    /*-------- NTP code ----------*/
    
    const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message
    byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets
    
    time_t getNtpTime()
    {
      while (Udp.parsePacket() > 0) ; // discard any previously received packets
      Serial.println("Transmit NTP Request");
      sendNTPpacket(timeServer);
      uint32_t beginWait = millis();
      while (millis() - beginWait < 1500) {
        int size = Udp.parsePacket();
        if (size >= NTP_PACKET_SIZE) {
          Serial.println("Receive NTP Response");
          Udp.read(packetBuffer, NTP_PACKET_SIZE);  // read packet into the buffer
          unsigned long secsSince1900;
          // convert four bytes starting at location 40 to a long integer
          secsSince1900 =  (unsigned long)packetBuffer[40] << 24;
          secsSince1900 |= (unsigned long)packetBuffer[41] << 16;
          secsSince1900 |= (unsigned long)packetBuffer[42] << 8;
          secsSince1900 |= (unsigned long)packetBuffer[43];
          return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;
        }
      }
      Serial.println("No NTP Response :-(");
      return 0; // return 0 if unable to get the time
    }
    
    // send an NTP request to the time server at the given address
    void sendNTPpacket(IPAddress &address)
    {
      // set all bytes in the buffer to 0
      memset(packetBuffer, 0, NTP_PACKET_SIZE);
      // Initialize values needed to form NTP request
      // (see URL above for details on the packets)
      packetBuffer[0] = 0b11100011;   // LI, Version, Mode
      packetBuffer[1] = 0;     // Stratum, or type of clock
      packetBuffer[2] = 6;     // Polling Interval
      packetBuffer[3] = 0xEC;  // Peer Clock Precision
      // 8 bytes of zero for Root Delay & Root Dispersion
      packetBuffer[12]  = 49;
      packetBuffer[13]  = 0x4E;
      packetBuffer[14]  = 49;
      packetBuffer[15]  = 52;
      // all NTP fields have been given values, now
      // you can send a packet requesting a timestamp:                 
      Udp.beginPacket(address, 123); //NTP requests are to port 123
      Udp.write(packetBuffer, NTP_PACKET_SIZE);
      Udp.endPacket();
    }

  2. #2
    Junior Member
    Join Date
    Feb 2016
    Posts
    15
    FYI: This datasheet for the adapter shows its schematic and pin mapping.
    Click image for larger version. 

Name:	teensy_adapter_datasheet.png 
Views:	969 
Size:	92.5 KB 
ID:	6502

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    I'll take a look, but at the very least I'll need to get that Sparkfun adaptor.

    Are you using the Arduino Ethernet shield, or an off-brand version? Arduino's made a few different versions of their ethernet shield. The one I have here says "R3", and it's definitely genuine Arduino.

    I know this may seem like minor details, but often these little things matter a lot. Please let me know exactly which shield you're using, so I can test with the exact same hardware setup.

  4. #4
    Junior Member
    Join Date
    Feb 2016
    Posts
    15

    Lightbulb

    Quote Originally Posted by PaulStoffregen View Post
    Are you using the Arduino Ethernet shield, or an off-brand version?
    This board doesn't have any maker markings on it, but I've managed to identify it as a RioRand (TM) Upgraded Ethernet Shield W5100 for Arduino UNO R3. It's tricky picking genuine hardware out of a lineup unless you know what to look for (thx for the description), and I'm personally not too crazy about the words "off-brand", so I'm going to pick up a genuine Arduino Ethernet Shield R3 on Amazon this weekend and re-run the sketch with it. If it gives me the same issue, I will bump this thread.

    Thanks, Paul. You're awesome!

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    I also put an order into Sparkfun

  6. #6
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    If you must buy new hardware is suggest you buy a WIZ820io Ethernet Module either from Saeligor from Mouser and the Proper adapter board from PJRC.
    It'll cost a bit more but works out of the box. The WIZ820io is also much more performannt as it is based on the newer W5200 chip.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Agreed, the W5200 chip is better.

    But I really do want to get to the bottom of why that particular Sparkfun product isn't working with the Arduino Ethernet Shield. Well, assuming the problem happens with the genuine Arduino shield. If it only happens on a cheap clone shield, probably not worth investigating.

  8. #8
    Junior Member
    Join Date
    Feb 2016
    Posts
    15
    Quote Originally Posted by Headroom View Post
    If you must buy new hardware is suggest you buy a WIZ820io Ethernet Module either from Saeligor from Mouser and the Proper adapter board from PJRC.
    It'll cost a bit more but works out of the box. The WIZ820io is also much more performannt as it is based on the newer W5200 chip.
    @Headroom: the suggestion is much appreciated and I will definitely look into this in the future, but this project also needs to interface with other Arduino-standard shields, so the Teensy Adapter board is necessary and there wouldn't be enough vertical clearance to mount the WIZ820io and SD adapter without it impacting the other shields.

  9. #9
    Junior Member
    Join Date
    Feb 2016
    Posts
    15
    Double-checking prior to purchase: this is the official Arduino Ethernet R3 board?

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    No, don't buy that one. That's the Arduino.org product. It's a Uno and Ethernet shield together, not a shield to be used on other boards.

    And honestly, don't buy from Amazon. Too many counterfeiters!
    Last edited by PaulStoffregen; 03-01-2016 at 11:47 AM.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Hmmm, Arduino doesn't have it in their own store, and Adafruit's out of stock

    https://www.adafruit.com/products/201

    But I can confirm the genuine R3 shield I have here perfectly matches that photo on Adafruit #201.

  12. #12
    Junior Member
    Join Date
    Feb 2016
    Posts
    15
    Quote Originally Posted by PaulStoffregen View Post
    That's the Arduino.org product.
    Knowing that there's an "Arduino.org" that makes their own hardware explains a lot... The more I look around, the more I wonder how those of us without genius-level electronics knowledge (and a touch of OCD) can competently differentiate between all of these products, makers, and specs. Still looking...

  13. #13
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    Quote Originally Posted by zurielseven View Post
    Knowing that there's an "Arduino.org" that makes their own hardware explains a lot... The more I look around, the more I wonder how those of us without genius-level electronics knowledge (and a touch of OCD) can competently differentiate between all of these products, makers, and specs. Still looking...
    Well, you don't have to differentiate. Teensy boards are clearly the better Arduino boards ;-)

  14. #14
    Junior Member
    Join Date
    Feb 2016
    Posts
    15
    Quote Originally Posted by Headroom View Post
    Well, you don't have to differentiate. Teensy boards are clearly the better Arduino boards ;-)
    You'll get no argument from me on that! Its one of the reasons that I am adapting Arduino hardware for control by Teensy. :-) I worked with Arduino UNO units for about a month before I learned of Teensy3. I bought my first unit a week after and haven't been inclined to shift back at all in the 2 years since.

  15. #15
    Junior Member
    Join Date
    Feb 2016
    Posts
    15
    Quote Originally Posted by PaulStoffregen View Post
    Hmmm, Arduino doesn't have it in their own store, and Adafruit's out of stock

    https://www.adafruit.com/products/201
    Ran into a major snag - according to my recent contact of Arduino.cc regarding the Ethernet R3 shield: the Arduino Ethernet is currently out of production and I have no estimated time for its availability.

  16. #16
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Yeah, it's not looking good for Arduino's shield.

    I ordered one of those RioRand clones. Already got a shipping notice, but looks like it's coming from China by postal mail. Might be a couple weeks 'til it arrives.

    Sparkfun shipped the adaptor board. Maybe I'll get lucky and be able to reproduce the problem with the R3 shield. If not, we'll probably have to wait for the RioRand to arrive before I can figure this out.

  17. #17
    Junior Member
    Join Date
    Feb 2016
    Posts
    15
    Quote Originally Posted by zurielseven View Post
    Ran into a major snag - according to my recent contact of Arduino.cc regarding the Ethernet R3 shield: the Arduino Ethernet is currently out of production and I have no estimated time for its availability.
    FYI: Until further notice, there are no more Arduino.cc Ethernet R3 shields being manufactured, nor are they working on a new shield. For best and most assured compatibility with Teensy hardware, the Wiz820io is the hardware of choice.

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Sorry for the long delay. Both the Sparkfun adaptor and the no-name Arduino Ethernet shield arrived a couple weeks ago, but I couldn't get to testing until now.

    I have some extremely bad news. The Sparkfun adaptor appears to have a serious design flaw. The 3.3V power is connected to pin 2 on the SPI connector, which is meant to be 5V. This destroyed the ethernet shield the first moment I plugged it in, because the shield has that pin wired to 5V power. This shorts the 3.3V and 5V power wires together when the shield is plugged into Sparkfun's adaptor. I measured 4.7V at the 3.3V pin on the shield. I plugged the shield into an Arduino Uno, and indeed it is dead. Very bad.

    Click image for larger version. 

Name:	SparkFun_Teensy_Adapter.png 
Views:	107 
Size:	37.6 KB 
ID:	6957

    I had only soldered the 28 outside pins for Teensy. If the other 5 pins on the end are soldered, the Teensy will probably also be killed. It seems Sparkfun only connected between the 3.3V pin on the right side of Teensy, the 3.3V pin going to the shield, and pin 2 of the SPI connector (but not to the 3.3V pin on Teensy between pin 23 and AGND), so Teensy survives if only the outside 28 pins are soldered. Unfortunately, the W5100 chip on the Ethernet shield is killed.

    Edit: I've opened a bug report on github.
    Last edited by PaulStoffregen; 04-10-2016 at 11:25 AM.

  19. #19
    Junior Member
    Join Date
    Feb 2016
    Posts
    15

    Unhappy

    Quote Originally Posted by PaulStoffregen View Post
    Sorry for the long delay. Both the Sparkfun adaptor and the no-name Arduino Ethernet shield arrived a couple weeks ago, but I couldn't get to testing until now.

    I have some extremely bad news. The Sparkfun adaptor appears to have a serious design flaw. The 3.3V power is connected to pin 2 on the SPI connector, which is meant to be 5V. This destroyed the ethernet shield the first moment I plugged it in, because the shield has that pin wired to 5V power. This shorts the 3.3V and 5V power wires together when the shield is plugged into Sparkfun's adaptor. I measured 4.7V at the 3.3V pin on the shield. I plugged the shield into an Arduino Uno, and indeed it is dead. Very bad.

    Click image for larger version. 

Name:	SparkFun_Teensy_Adapter.png 
Views:	107 
Size:	37.6 KB 
ID:	6957

    I had only soldered the 28 outside pins for Teensy. If the other 5 pins on the end are soldered, the Teensy will probably also be killed. It seems Sparkfun only connected between the 3.3V pin on the right side of Teensy, the 3.3V pin going to the shield, and pin 2 of the SPI connector (but not to the 3.3V pin on Teensy between pin 23 and AGND), so Teensy survives if only the outside 28 pins are soldered. Unfortunately, the W5100 chip on the Ethernet shield is killed.

    Edit: I've opened a bug report on github.
    Thank you for this information, Paul - that is indeed difficult to hear. I'm going to take a hard look at the hardware requirements for my project and start considering some workarounds (some of which may not be so pretty as I'd like). Your time and effort spent on this is greatly appreciated!

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    FWIW, this issue is still on my list to investigate. Tomorrow I'm going to order another no-name ethernet shield and retest with SPI pin 2 disconnected.

  21. #21
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    The replacement "RioRand" Arduino ethernet shield arrived. I tested again, and it works with these steps:

    1: You *must* remove pin 2 of the SPI connector. If the connector is already soldered, just cut it off.

    2: The 3.3V pin near Teensy's pushbutton must be soldered to the Sparkfun adaptor. The 3.3V pin between AGND and pin 23 isn't connected.

    3: (optional) IOREF should be connected to 3.3V. This shield doesn't use it, but some others do.

    4: A 10K resistor must be added between RESET and 3.3V.

    Click image for larger version. 

Name:	ethshield.jpg 
Views:	201 
Size:	109.1 KB 
ID:	7106

  22. #22
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    I created these images to document the steps. Hopefully Sparkfun will add them to their product page....

    Click image for larger version. 

Name:	sparkfun13288_errata1.jpg 
Views:	134 
Size:	105.2 KB 
ID:	7110

    Click image for larger version. 

Name:	sparkfun13288_errata2.jpg 
Views:	141 
Size:	73.0 KB 
ID:	7109

    Click image for larger version. 

Name:	sparkfun13288_errata3.jpg 
Views:	144 
Size:	104.0 KB 
ID:	7108

    Click image for larger version. 

Name:	sparkfun13288_errata4.jpg 
Views:	190 
Size:	116.8 KB 
ID:	7107

  23. #23
    Junior Member
    Join Date
    Feb 2016
    Posts
    15
    Thank you, Paul. I will be making these updates presently. :-) I do hope that SparkFun is able to make the updates to the board. Since the Eagle files are available on their site, I am considering making the updates myself (with the benefit of your suggestions above) and seeing about having a few "corrected" boards manufactured for assembly.

  24. #24
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,814
    Looking at this shield on SparkFun they have this note on the Hookup Guide:

    Warning! If you are using a 5V shield that connects over the SPI pins, do not connect SPI pin 2 on the adapter to your shield. This will short 3.3V and 5V together and could damage your Teensy.

  25. #25
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Well, at least they added that note, and "This adapter may be incompatible with some 5V Arduino shields. Please check our hookup guide for more information." on the product page.

    Kinda underwhelming for an issue that destroys hardware, but better than no warning at all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •