Teensy3.2 - WIZ850io problem

I am having trouble getting Teensy 3.2 to work with WIZ850io (W5500) Ethernet module.
I have run the attached sketch on a mega2560 with Ethernet shield attached and this works fine. ( printout attached. I have connected Teensy3.2 to WIZ850io as per attached note and run the same sketch with the target processor set to Teensy 3.2. The attached printout shows that the code gets past the initialization of the WIZ859io in the case where the ethernet connector is connected to a hub and if it is not connected to a hub the code times out without a connection. However when the Ethernet is connected after passing the initialization, the code hangs at the Udp.beginPacket(address, Port); function call. It does not get past this point and nothing is received on my Ethernet monitoring.

printout and connection information:

TeensyNoEthernetConnection after waiting some time:


we have serialstarting EtherrnetFailed to configure Ethernet using DHCP


TeensyEthernetConnection:


we have serialstarting Etherrnetstarting UDPwe have local port setuprunning tic
32770 5 6 23191


running same cosde on megga2560 with W5100 shield:


we have serial
starting Etherrnet
starting UDP
we have local port setup
running tic

-32766 5 6 7 8
-32766 10 12 14 16
-32766 15 18 21 24
-32766 20 24 28 32
-32766 25 30 35 40
-32766 30 36 42 48
-32766 35 42 49 56
-32766 40 48 56 64
-32766 45 54 63 72
-32766 50 60 70 80
-32766 55 66 77 88
-32766 60 72 84 96
-32766 65 78 91 104
-32766 70 84 98 112
-32766 75 90 105 120


’ etc…


Teensy3.2 - WIZ850io connections:
GND Gnd
Vin 3.3V
12 MISO
11 MOSI
10 SCNn
13 SCLK

Here is the sketch:

/* Test for setup and running ethernet W5500 from Teensy 3.2
*/

#define ledPin 13  // LED connected to digital pin 13
#include <Ethernet.h>
//#include <EthernetUdp.h>


/*
 *   globals
 */
const int PACKET_SIZE = 48;         //
typedef struct SYS {
                                    // Timer system variables
  unsigned long  tic_next;
  unsigned long  tic_period;
  unsigned long  tic_last;
  unsigned long  tic_dif;
                                    // Communication System variables
  unsigned int localPort = 4000;    // local port to listen for UDP packets
};
SYS S;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };          // MAC address
char broadcastAddr[] = "255.255.255.255"; // broadcast address URL
byte packetBuffer[ PACKET_SIZE];    //buffer to hold incoming and outgoing packets
byte packetBuffer3[ 8];             //buffer to hold incoming and outgoing packets
const int PACKET_SIZE_AB = 12;      // size of measurement data packet 6 ints
byte pktBufA[ PACKET_SIZE_AB];      // buffer to hold measurement data
int *PtrIA;                          // integer pointer to buffer A

int *PtrI;
char *PtrC;
int *PtrI3;

typedef struct UDPDatStruct {
  unsigned short numblocks;
  unsigned short numinblock;
  unsigned short data[];
} UDPDatStruct;

EthernetUDP Udp;                    // A UDP instance to let us send and receive packets over UDP



/*
 *   function prototypes
 */
void systemTic( void);
void sampleQueue( void);
void sendUDP(char* address, unsigned int Port, void * Buf, int Size);
void sendSysParams( void);


void setup() {
  pinMode(ledPin, OUTPUT);  // initialize digital pin LED_BUILTIN as an output.

  PtrC = (char *)&packetBuffer3[0];
  PtrI3 = (int *)PtrC;
  PtrC = (char *)&packetBuffer[0];
  PtrI = (int *)PtrC;
  PtrIA = (int *)pktBufA;          // set integer pointer to buffer A

  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("\nwe have serial");

  Serial.println("starting Etherrnet");
  // start Ethernet and UDP
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for (;;)      // will hang if no HUB connected to ethernet switch
      ;
  }
  Serial.println("starting UDP");
  Udp.begin(S.localPort);
  Serial.println("we have local port setup");
  Serial.println("running tic");
  systemTic();
}


void loop() {
  //Serial.print("lockup system:\n");
  delay(10000);
}


//  systemTic
//
void systemTic( void) {
  S.tic_period = 500000UL;      // 02 Hz
  S.tic_last = micros();
  for(;;) {
    S.tic_next = S.tic_last + S.tic_period;       // set next tic
sampleQueue();
sendSysParams();
sendUDP( broadcastAddr, 4000, PtrIA, PACKET_SIZE_AB);
    for(;;) {                               // wait for next tic epoc
      S.tic_dif = S.tic_next - micros();
      if ( S.tic_dif & 0x80000000 ) {
        S.tic_last = S.tic_next;
        S.tic_next = S.tic_last + S.tic_period;
        break;
      }
    }
  }
}


void sendSysParams( void) {
  Serial.print("\n");
  Serial.print(PtrIA[0]);
  Serial.print("\t");
  Serial.print(PtrIA[1]);
  Serial.print("\t");
  Serial.print(PtrIA[2]);
  Serial.print("\t");
  Serial.print(PtrIA[3]);
  Serial.print("\t");
  Serial.print(PtrIA[4]);
}




// sampleQueue
//
void sampleQueue( void) {
    PtrIA[0] = 0x8002;
    PtrIA[1] = PtrIA[1] + 5;
    PtrIA[2] = PtrIA[2] + 6;
    PtrIA[3] = PtrIA[3] + 7;
    PtrIA[4] = PtrIA[4] + 8;
}


// send UDP data
//
void sendUDP(char* address, unsigned int Port, void * Buf, int Size) {
  //Serial.println("\nset address, port");
  Udp.beginPacket(address, Port);
  //Serial.println("write Buf, size");
  Udp.write((char *)Buf, Size);
  //Serial.println("end packet");
  Udp.endPacket();
}

I do not know what to do to get this working.

Please help
Regards
Clem.

Hey Clem,

Interesting problem, I haven’t experienced anything like this particular incident before but I’ll see what information I can find for you in regards to resolve this error. The libraries and forums that I’ve linked below should have some useful information in possibly troubleshooting the error in this situation.

https://www.pjrc.com/teensy/td_libs_Ethernet.html

All the best with your project!

Bryce
Core Electronics | Support

Hi Bryce,

I could not see any help from the links you posted.

I am not sure if my development system is set up correctly?

I have installed the TeensyDuino form the link - but I am not sure if how to use this - is this just attached to the arduino IDE and am I supposed to run a different development system? I see no difference as a result of installing the TeensyDuino.

I have also installed a library ( PaulStoffregen/Ethernet). I assume that I have installed it correctly, but as such it makes no difference to the way the IDE looks.

I would have thought that installing the Ethernet library for the teensy would give an example script for the teensy to choose from which has Ethernet functionality - but I see nothing.

Please advise.
Clem

Hi Clem,

In response to your questions.

Also, did you use #include <Libraryname.h> without commenting out “//” at the beginning of your script? As otherwise it won’t be included when uploading. Could you please send through some photos of your rig? This generally also assists in troubleshooting. Have a great day!

Bryce
Core Electronics | Support

Some pictures of my setup:

at the moment I am no closer to solving this problem.

I note you say £include <libraryname.h>
what is the libraryname?

I have connected the Wiz850 V pin to the Teensy 3.3V instead of the Teensy Vin pin.

Regards

I have tried putting a pulse on the reset pin and it does not help

I have tried replacing the WIZ850io module with another one and it does the same thing

I have tried replacing the WIZ850 module with one with a W5100 chip and it crashes in the chip initialization.

do not know what to do now - this is supposed to be easy straight forward work out of the box!

Hi Clem,

Thanks for sharing those images. Nothing stands out straight away to me.

Hmm, failing someone else piping in with experience with those two boards, it might also be worth checking in with the community at PJRC.

I have not been able to get this to work in the current configuration. I have tried an example from the teensy OSC examples and this sends data over the Ethernet - so the hardware works - there is some problem with the software or libraries and it is not the reset pin. I have tried the reset pulse and it makes no difference. I am not using the reset pin on the OSC example and it works. I do not know what the problem is but will have to move on to what does work.

Hi Clem,

No worries, I was referring to this particular line being commented out, to confirm that there were no dependencies within the script. As Graham said the PJRC community would likely be best suited for this issue.

Have a great day!

Bryce
Core Electronics | Support