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

Thread: Teensy 3.2 - WIZ850io Ethernet module - not working

  1. #1

    Teensy 3.2 - WIZ850io Ethernet module - not working

    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 attached:


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

    I have uninstalled the Arduino environment and reinstalled V 1.8.12
    did not help

    Please help
    Regards
    Clem.


    /* 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();
    }

  2. #2
    I've had one of those modules working with my 3.2, not sure what the issue could be, i used the adafruit libs

    #include <Adafruit_WINC1500.h>

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,272
    Delete this line, and any others accessing pin 13.

    Code:
    pinMode(ledPin, OUTPUT); // initialize digital pin LED_BUILTIN as an output.
    On Teensy 3.2, pin 13 is used for SCK. Simply having the LED on the same pin is ok, but using these functions to access the pin can interfere with SPI.

    I believe Arduino Mega uses a different pin for SCK, avoiding this possibly conflict.

Posting Permissions

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