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

Thread: Teensy++2.0 Wiz811MJREV1.0 Teensyduino 1.40 vs 1.41 Arduino 1.85

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Location
    New Jersey USA
    Posts
    13

    Teensy++2.0 Wiz811MJREV1.0 Teensyduino 1.40 vs 1.41 Arduino 1.85

    Hi All,

    Ethernet stopped working when I went from Teensy 1.40 to 1.41. When I run arp I get "(incomplete)" for the MAC address. The other clue is that the GLCD.Print(After Begin) takes about 1 or 2 seconds with 1.40 but happens immediately with 1.41. Libraries used were all teensduino supplied except for openGLCD.
    Any suggestions?

    Here's the code:

    Code:
    #include <SPI.h>
    #include <openGLCD.h>
    #include <Ethernet.h>
    
    #define BACKLIGHT_PIN  0
    #define WIZNETRESET_PIN 24
    byte mac[] = { 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xE0 };
    //IPAddress ip{192, 168, 5, 50};
    
    EthernetServer server(80);
    
    void setup()
    {
        BackLight(255);
        GLCD.Init();
        GLCD.ClearScreen(); 
        GLCD.SelectFont(System5x7, BLACK);
        GLCD.CursorTo(0,0); /* col row */
        GLCD.Puts("Ethernet Test");
        
        pinMode(WIZNETRESET_PIN, OUTPUT);
        digitalWrite(WIZNETRESET_PIN, LOW);
        delay(1);
        digitalWrite(WIZNETRESET_PIN, HIGH);
        delay(1);
        
        Ethernet.begin(mac); //, ip);
        server.begin();
    
        GLCD.CursorTo(0,1); /* col row */
        GLCD.Printf("%s", "after begin");
    }
    
    void loop()
    {
        char    *buf;
        byte  cnt = 0;
        int x = 0;
        
        EthernetClient client = server.available();
        if (client)
        {
            if(client.connected())
            {
                x=0;
                cnt = client.available();
                buf = (char*)calloc(cnt+1, sizeof(char));
                GLCD.CursorTo(0, 1);
                GLCD.Printf("cnt=%d", cnt);
                GLCD.CursorTo(0, 2);
                for(x=0; x<cnt; x++)
                {
                    buf[x] = client.read();
                    GLCD.Printf("%c", buf[x]);
                }
                buf[cnt] = NULL;
    
                client.println("HTTP/1.1 200 OK");
                client.println("Content-Type: text/html");
                client.println();
                
                client.println(cnt);
                client.println(buf);
                free(buf);
            }
            // give the web browser time to receive the data
            delay(1);
            client.stop();
        }
    }
    void BackLight(byte pwm_value)
    {
        analogWrite(BACKLIGHT_PIN, pwm_value);
    }

  2. #2
    Junior Member
    Join Date
    Jan 2013
    Location
    New Jersey USA
    Posts
    13
    Some more testing. I have removed the glcd library. Version 1.40 works and 1.41 does not work. The Ethernet.begin(mac) call fails. It returns a 0 on version 1.41. On 1.40 it is successful. Can anyone see a problem in my code?
    Here's the code:

    Code:
    #include <SPI.h>
    #include <Ethernet.h>
    
    #define ledPin  6
    #define WIZNETRESET_PIN 24
    byte mac[] = { 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xE0 };
    
    long interval;
    int ledState = LOW;
    long previousMillis = 0; 
    
    EthernetServer server(80);
    
    void setup()
    {
        pinMode(WIZNETRESET_PIN, OUTPUT);
        pinMode(ledPin, OUTPUT);
        digitalWrite(ledPin, LOW);
        
        digitalWrite(WIZNETRESET_PIN, LOW);
        delay(1);
        digitalWrite(WIZNETRESET_PIN, HIGH);
        delay(1);
    
        if(Ethernet.begin(mac) == 0) //fail
          interval = 500;
        else                 //ok
          interval = 1000;
    
        server.begin();
    }
    
    void loop()
    {
        char *buf;
        int x, cnt;
        
        EthernetClient client = server.available();
        if (client)
        {
            if(client.connected())
            {
                cnt = client.available();
                buf = (char*)calloc(cnt+1, sizeof(char));
                
                for(x=0; x<cnt; x++)
                    buf[x] = client.read();
                buf[cnt] = (char)NULL;
    
                client.println("HTTP/1.1 200 OK");
                client.println("Content-Type: text/html");
                client.println();
                
                client.println(cnt);
                client.println(buf);
                free(buf);
            }
            // give the web browser time to receive the data
            delay(1);
            client.stop();
        }
        BlinkLed();
    }
    void BlinkLed()
    {
      unsigned long currentMillis = millis();
     
      if(currentMillis - previousMillis > interval) {
        // save the last time you blinked the LED 
        previousMillis = currentMillis;   
    
        // if the LED is off turn it on and vice-versa:
        if (ledState == LOW)
          ledState = HIGH;
        else
          ledState = LOW;
    
        // set the LED with the ledState of the variable:
        digitalWrite(ledPin, ledState);
      }
    }

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,191
    I'm currently traveling, so I can't look into this until next week. If you don't hear from me by Wednesday, please post again to bump this thread and I'll do some testing. I only have the WIZ812 module. Hopefully it's similar enough?

Posting Permissions

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