Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: Problems with teensy 3.1 and WIZ550io

  1. #1

    Problems with teensy 3.1 and WIZ550io

    I'm trying to use this module with a teensy 3.1

    http://www.wiznet.co.kr/sub_modules/...te3=0&pid=1196

    I loaded their new wiznet Ethernet library but when I try to compile any the examples using teensy 3 or 3.1 I get this error.
    What's wrong or what should I correct?
    Click image for larger version. 

Name:	Error 3.png 
Views:	588 
Size:	36.2 KB 
ID:	1806

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,964
    Opps, I missed this thread earlier.

    I just tried that link, but didn't see the code for Arduino. Could you post a direct link to the code you're using?

    This error looks similar to a problem with the original Ethernet library when Teensy 3.0 was released. Teensyduino installs a patched copy of Ethernet to fix the issue. The problem was poorly defined functions, like W5100Class::read_data, which used a pointer to pass a 16 bit integer.

    Here's the original code:

    Code:
    void W5100Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *dst, uint16_t len)
    Notice that "src" is a pointer to uint8_t. But here's how it's actually used:

    Code:
      src_mask = (uint16_t)src & RMASK;
    The pointer is never used to access any memory. It really is only a 16 bit unsigned integer.

    To port Ethernet to Teensy 3.0, I change that function to:

    Code:
    void W5100Class::read_data(SOCKET s, uint16_t src, volatile uint8_t *dst, uint16_t len)
    The code is already using src as uint16_t, so this is a simple fix.

    Then of course all the places which use read_data() need to update, to using uint16_t rather than uint8_t *. The bad news is it's quite a bit of work, to find and edit all those places. The good news is I already did it in Ethernet. Turns out the Arduino devs did something similar in their copy for Arduino Due. So either Ethernet after having installed Teensyduino, or a copy from Arduino 1.5.6, could serve as a template.

    Of course, this is assuming the problem is the same. I couldn't find the Arduino version of the code on that page you linked. If I had found it, I would have looked to make sure before writing all this.

    Hopefully this helps. I simply don't have an easier answer for you. Perhaps someday I'll merge W5500 support into Teensyduino's copy of Ethernet. It already supports both W5100 & W5200, automatically detected. But this is a very low priority, so low that odds are it'll probably never happen unless Wiznet discontinues the W5200 chip or Wiz820io module.

    This message one detailed message is all I intend to do on the W5500. Had the source been on that page, I would have looked. But I'm crazy busy getting stuff prepared for Maker Faire, so I really don't have more time for this unsupported hardware. You'll need to resolve the bugs (perhaps with a start from this message), or take the $20 path of least resistance with a Wiz820io module!

  3. #3
    Hi Paul and thank you for reply.

    I forgot to add. To use the Wiz 550io I had to download wiznet Ethernet library.

    Its kind of the same arduino library but adding the wiznet 5500 support.

    you can find it here: https://github.com/Wiznet/WIZ_Ethernet_Library

    I tried out modifying the read data class in the way you said: uint16_t instead of uint8_t but then it gives a lot of other errors compiling the code.


    I instead changed this line:

    Code:
    src_mask = (uint16_t)src & RMASK;
    to this

    Code:
    src_mask = (size_t)src & RMASK;
    in each of the 5xxx cpp file.

    By this way it should automatically size the pointer accordingly.

    Using this trick it compiles and it works if I use an Ethernet module with wiznet 5100 on the teensy 3.1.

    But if I use the wiz 550io it still doesn't work.

    Thi Is the testing code I'm using:

    Code:
    /*
      Web Server
     
     A simple web server that shows the value of the analog input pins.
     using an Arduino Wiznet Ethernet shield. 
     
     Circuit:
     * Ethernet shield attached to pins 10, 11, 12, 13
     * Analog inputs attached to pins A0 through A5 (optional)
     
     created 18 Dec 2009
     by David A. Mellis
     modified 9 Apr 2012
     by Tom Igoe
     modified 12 Aug 2013
     by Soohwan Kim
     
     */
    
    #include <SPI.h>
    #include <Ethernet.h>
    
    // Enter a MAC address and IP address for your controller below.
    // The IP address will be dependent on your local network:
    #if defined(WIZ550io_WITH_MACADDRESS) // Use assigned MAC address of WIZ550io
    ;
    #else
    byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
    #endif  
    IPAddress ip(192,168,2,177);
    
    // Initialize the Ethernet server library
    // with the IP address and port you want to use 
    // (port 80 is default for HTTP):
    EthernetServer server(80);
    
    void setup() {
     // Open serial communications and wait for port to open:
      Serial.begin(9600);
       while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }
    
    
      // start the Ethernet connection and the server:
    #if defined(WIZ550io_WITH_MACADDRESS)
      Ethernet.begin(ip);
    #else
      Ethernet.begin(mac, ip);
    #endif  
      server.begin();
      Serial.print("server is at ");
      Serial.println(Ethernet.localIP());
    }
    
    
    void loop() {
      // listen for incoming clients
      EthernetClient client = server.available();
      if (client) {
        Serial.println("new client");
        // an http request ends with a blank line
        boolean currentLineIsBlank = true;
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
            Serial.write(c);
            // if you've gotten to the end of the line (received a newline
            // character) and the line is blank, the http request has ended,
            // so you can send a reply
            if (c == '\n' && currentLineIsBlank) {
              // send a standard http response header
              client.println("HTTP/1.1 200 OK");
              client.println("Content-Type: text/html");
              client.println("Connection: close");  // the connection will be closed after completion of the response
    	  client.println("Refresh: 5");  // refresh the page automatically every 5 sec
              client.println();
              client.println("<!DOCTYPE HTML>");
              client.println("<html>");
              // output the value of each analog input pin
              for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                int sensorReading = analogRead(analogChannel);
                client.print("analog input ");
                client.print(analogChannel);
                client.print(" is ");
                client.print(sensorReading);
                client.println("<br />");       
              }
              client.println("</html>");
              break;
            }
            if (c == '\n') {
              // you're starting a new line
              currentLineIsBlank = true;
            } 
            else if (c != '\r') {
              // you've gotten a character on the current line
              currentLineIsBlank = false;
            }
          }
        }
        // give the web browser time to receive the data
        delay(1);
        // close the connection:
        client.stop();
        Serial.println("client disonnected");
      }
    }

    It works fine with a 5100 module; even with a 5200 module (I obviously go to change which module is defined everytime in utility/5100.cpp of the library)
    But with the 550io module It basically doesn't get the iP.

    Or almost it invents a random IP.

    Let's say I declared: 192.168.2.177 as an IP.

    If I open the serial monitor I see that it gets everytime a random Ip like: 0.188.2.0 or 188.255.0.0

    The weird thing is that if I disconnect the Ethernet cable; instead of giving 0.0.0.0 as Ip; it still gives random IP.


    I hooked up the module

    Module Teensy 3.1

    MOSI ----> Pin 11 Dout
    MISO-----> Pin 12 Din
    SCLK-----> PIn 13 Clock
    SCSN-----> Pin 10 SS

    and obviously the 3.3 volts and gnd.

    I tried same with an arduino but it still gives a random IP.

    Here is an image of my config as well

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,964
    Oh, one other issue in Ethernet (long since solved) was util.h.

    Here's the code that works on 32 bit platforms.

    Code:
    #define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) )
    #define ntohs(x) htons(x)
    
    #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
                       ((x)<< 8 & 0x00FF0000UL) | \
                       ((x)>> 8 & 0x0000FF00UL) | \
                       ((x)>>24 & 0x000000FFUL) )
    #define ntohl(x) htonl(x)

  5. #5
    Quote Originally Posted by PaulStoffregen View Post
    Oh, one other issue in Ethernet (long since solved) was util.h.

    Here's the code that works on 32 bit platforms.

    Code:
    #define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) )
    #define ntohs(x) htons(x)
    
    #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
                       ((x)<< 8 & 0x00FF0000UL) | \
                       ((x)>> 8 & 0x0000FF00UL) | \
                       ((x)>>24 & 0x000000FFUL) )
    #define ntohl(x) htonl(x)

    It compiles and upload but still give me a wrong ip address: 0.188.188.188 both with cable connected or disconnected

  6. #6
    Any suggestions?

  7. #7
    Anyone ? still getting random IP's or 0.0.0.0 when cable is connected

  8. #8
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    Do yourselves a favor and get a WIZ820io. That works out of the box with the Teensy 3.x and is smaller than the WIZ550io. Other than the builtin MAC address I don't see any advantages of the WIZ550io over the WIZ820io. With each Teensy 3.x having a unique MAC address burned in, the WIZ550io is somewhat superfluous in a Teensy 3.x environment.

    If you like the learning experience, then hack away, otherwise....

  9. #9
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    The WIZ550io... marketed to IoT folks. My first reaction to it was (and still holds) - why would I choose that over the 820io???

  10. #10
    I have an Update

    I installed yesterday the new teensyduino update 1.19 and now it works perfectly Without no troubles and no errors

    Thanks a lot for the help

  11. #11
    Ok this is strange. I updated to teensyduino 19 and the modules started to work on teensy 3.1 and 2++; however; they don't work with traditional arduinos.


    I know 820io is easier to use but i got these modules and i have to use them

  12. #12
    I've started in on using the w550io, and with some changes to the Wiznet library it seems to be working fine.

    My work can be found at astronouth7303/Ethernet.

    It does not yet include improvements from SPI transactions and such, but does include Wiznet's 1.5 branch. Patches accepted.

  13. #13
    Quote Originally Posted by astronouth7303 View Post
    I've started in on using the w550io, and with some changes to the Wiznet library it seems to be working fine.

    My work can be found at astronouth7303/Ethernet.

    It does not yet include improvements from SPI transactions and such, but does include Wiznet's 1.5 branch. Patches accepted.
    still doesn't work on teensy 3.1


    it does However work on teensy 2 ++

  14. #14
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,964
    If anyone's still watching this old thread, I've started working on W5500 support.

    Details here:
    https://forum.pjrc.com/threads/28642...948#post121948

Tags for this Thread

Posting Permissions

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