SPI LEGACY ETHERNET COMMUNICATION WITH TEENSY 4.1

I'm trying to use a Teensy 4.1 in a board I designed for v3.5 as the 3.5 units are no longer available. I've modified the board for the 3.3v input compatibility, but I can't get the original SPI ethernet interface to connect to my WIZNET WIZ811MJ ethernet device. All other code, including the LCD library are working. The SPI pin numbers on v4.1 appear to be the same as v3.5. I use pin #9 to reset the Wiznet.

Is is possible that the Arduino compiler doesn't load the compatible ethernet library when compiling for a 4.1 device?
I've listed the relevant code snippets. The SPI pin numbers are shown. Is there additional code required to use the older ethernet library on a 4.1?
I use the following compiler versions (because I can't upload sketches properly on my workstation with current versions)
Ardino 1.8.13
Teensyduino 1.53

Code:
//ETHERNET PINS
#define PIN_ETHERNET_RESET             9
#define PIN_ETHERNET_SCS               10
#define PIN_ETHERNET_MOSI              11
#define PIN_ETHERNET_MISO              12
#define PIN_ETHERNET_SCLK              13

//Include Standard Ethernet Library
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(198, 0, 0, 4);

// Initialize Ethernet Reset Pin To High
  pinMode(PIN_ETHERNET_RESET, OUTPUT);
  digitalWrite(PIN_ETHERNET_RESET, HIGH);

// Reset The Wiznet 811MJ
  digitalWrite(PIN_ETHERNET_RESET, LOW);
  digitalWrite(PIN_ETHERNET_RESET, HIGH);

 m_server = new EthernetServer(12345);

//Initialize Ethernet Library
  Ethernet.begin(mac_address, ip);
  //Start Ethernet Server
  m_server->begin();

I appreciate your thoughts.
 
I don’t personally have experience with that library, but I recently made the QNEthernet library work with the W5500 if you’d like to try it out. You don’t even need to set a MAC address; it uses the Teensy’s internal one.

Simply do these steps:
1. Uncomment // #define QNETHERNET_DRIVER_W5500 in src/qnethernet_opts.h.
2. In src/drivers/drivers_w5500_config.h, change the spi line to point to whichever SPI port you'd like to use. For example, for the default, leave as-is. (It looks like you have the default set up.) For SPI2, set to SPI2 instead of SPI, etc.
3. Include <QNEthernet.h> instead of <Ethernet.h>.
4. Add using namespace qindesign::network; after the includes.
5. Call Ethernet.begin() to use DHCP and Ethernet.begin(ip, netmask, gateway) to use a static IP. (Instead of what you have; the netmask and gateway aren't really well-defined for that version of the function.)
6. Optionally check out some of the examples for some ways to do things.

Update: I just realized you're using a WIZ811MJ and not a W5500... Let me have a peek at the datasheet for that... Does the "Ethernet" library even support that chip?
Update 2: Looks like that module has the W5100 on it, and I'm fairly certain the "Ethernet" library should work with that. I'm sorry to say that I haven't (maybe yet) added support for that one in the QNEthernet library.
 
Last edited:
Is is possible that the Arduino compiler doesn't load the compatible ethernet library when compiling for a 4.1 device?

Unlikely. I personally test Ethernet.h with a W5500 on every release.

But you can easily check which library Ardiuno IDE is really using by turning on verbose output during compile in File > Preferences. Then compile and scroll up to read the messages. You'll see a list of all the libraries Arduino IDE used with the full pathnames.


I appreciate your thoughts.

Try adding delays between those digitalWrite for the reset pin. Teensy 4.1 runs much faster, so your reset pulse will become much shorter without delays.

Also, check which version of Teensyduino you have installed. 3 years ago a timing issue was fixed that affected only the W5100 chip by adding a 10ns delay. If you have a very old version, maybe you still have the old Ethernet library without that 10ns delay?
 
Update: I just realized you're using a WIZ811MJ and not a W5500... Let me have a peek at the datasheet for that... Does the "Ethernet" library even support that chip?

Yes, the Ethernet.h library supports Wiznet W5100, W5200, W5500 chips.
 
Back
Top