Teensy 3.5 & wiz820 ethernet UDP speed problem

Status
Not open for further replies.

microguy

Member
Hi,

I try to send some UDP packet from a first Teensy 3.5 with wiz820 eth module to a 2nd Teensy 3.5 with wiz820 eth module and a straight cable between the two.

First : when I send packet from the first Teensy to my computer, packet are sent with the right timing : each 20ms ---> no problem
second: when I send packet from my computer to my second Teensy, Teensy received packet ---> no problem

But when I send packet from the first Teensy to nothing or to the second Teensy, timing are very bad (send packet?? every 2s) and the second teensy never received any packet...

Do you Know, why the first Teensy seems to wait for something? slow down and never send the packet? and try each 2s instead of 20ms?

Code:
#include <Ethernet.h>
#include <EthernetUdp.h>

//FOR ETHERNET:
#define ethRSTpin 9
#define ethCSpin 10
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // MAC and IP controller address 
IPAddress ip(192, 168, 1, 178);
unsigned int localPort = 8888;  // local port to listen on    
EthernetUDP Udp;  // An EthernetUDP instance to let us send and receive packets over UDP

elapsedMillis TsincelastUDPOut; // increase as time elapses. will be reseted after each UDP send
int RefreshT = 20; //interval beetwen two UDP send


void setup() {

  // set serial com
  Serial.begin(9600);
  delay(3000);
  Serial.println("HELLO");

  //Start wiz ethernet module 
  pinMode(ethRSTpin, OUTPUT);
  digitalWrite(ethRSTpin, LOW);
    delay(1000);
  digitalWrite(ethRSTpin, HIGH);
    delay(1000);
  
  Ethernet.init(ethCSpin);  // Ethernet.init(pin) to configure the CS pin
  Ethernet.begin(mac,ip);  // start the Ethernet
  delay(500);

  // start UDP
  Udp.begin(localPort);
  Serial.println("End of Ethernet init");
  delay(1000);
}
//END OF INIT

void loop() {

    if (TsincelastUDPOut >= RefreshT) {
    TsincelastUDPOut = TsincelastUDPOut - RefreshT;
    Serial.println("send");
    char dataOut[11]= "speed test";
    
    Udp.beginPacket("192.168.1.174",8888);
    Udp.write((byte *)&dataOut,sizeof dataOut);            //Write packet which contains data structure 
    Udp.endPacket();                                       //Close Packet and send
    }
    }
 
Last edited:
are you using an ethernet crossover cable between the two wiznet modules? (Rx to Tx, Tx to Rx) I don't think wiznet supports auto MDI-X
 
No, I'm using a normal cable but the wiz820 dtasheet says : "Supports auto-negotiation and auto cross-over detection", so I think it's OK?
 
OK, now, I can send and receive with good timing...but I have to follow a startup sequence. start receiver before sender... very strange. If not, sender never start....It tries every 2s but without success
 
No more problem: I just add this on setup:

Code:
  if(Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
    while (Ethernet.linkStatus() == LinkOFF) {
      delay(1);
  }
  }

maybe it can help others...
 
Status
Not open for further replies.
Back
Top