-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ethernet library issue with W5500 #7654
Comments
Could you try git version of this core ? Both include https://github.com/arduino-libraries/Ethernet version. |
thanks a lot for your fast reply dav and all the work! Here is now my full feedback :
I wrote the following piece of code that include the ethernet usage: MCVE Sketch #include <SPI.h>
#include <Ethernet.h>
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
long loopElapsedTime = 0;
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h
void setup() {
Serial.begin(115200);
while (!Serial);
tft.init(); tft.fillScreen(TFT_BLACK); tft.setTextColor(TFT_WHITE,TFT_BLACK);
loopElapsedTime = millis();
Ethernet.init(D2); // ESP8266 with Adafruit Featherwing Ethernet
Serial.print("\nCode before TFT call. Initialize Ethernet with DHCP: ");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
while (1); // do not continue
}
Serial.println(Ethernet.localIP()); // at that point in time we have an IP address and linkstatus is LinkON
Serial.printf(" link: %i",Ethernet.linkStatus());
}
void loop() {
if ((millis() - loopElapsedTime) > 1000){
loopElapsedTime = millis();
Ethernet.maintain(); // maintain does no change anything to the issue
tft.setCursor(0, 0, 2);
tft.print(loopElapsedTime); // as soon as we call a tft function that activate the SPI device, the Ethernet driver turn to LinkOFF and unset IP address
// if you comment this call, then all works fine
Serial.printf("\nCode after TFT call. link: %i",Ethernet.linkStatus());
Serial.print("\nIP: ");
Serial.print(Ethernet.localIP());
}
}
### Debug Messages
Here is what you get on serial line:
12:45:54.326 -> Code before TFT call. Initialize Ethernet with DHCP: 192.168.0.211
12:45:55.017 -> link: 1
12:45:55.345 -> Code after TFT call. link: 2
12:45:55.345 -> IP: (IP unset)
and here is the TFT user test config:
12:25:51.784 -> [code]
12:25:51.784 -> TFT_eSPI ver = 2.2.14
12:25:51.784 -> Processor = ESP8266
12:25:51.784 -> Frequency = 80MHz
12:25:51.784 -> Voltage = 3.32V
12:25:51.784 -> Transactions = No
12:25:51.784 -> Interface = SPI
12:25:51.784 -> SPI overlap = No
12:25:51.784 ->
12:25:51.784 -> Display driver = 7735
12:25:51.784 -> Display width = 128
12:25:51.784 -> Display height = 160
12:25:51.784 ->
12:25:51.784 -> TFT_CS = PIN_D1
12:25:51.784 -> TFT_DC = PIN_D8
12:25:51.784 ->
12:25:51.784 -> Display SPI frequency = 27.00
12:25:51.784 -> [/code]
### Problem Description
The setup works good, the TFT is properly initiated and the W5500 module is assigned an IP address correctly
However as soon as we call a function that engage the SPI bus (in my case the TFT screen), looks like the Ethernet module loose its IP address and the link turn to OFF
It continues to work as you can still call HardwarStatus and check Link function and the TFT is also displaying properly
I suspect an implementation issue in the w5500 or ethernet code regarding switching from one device to another on the SPI bus
|
I can see in your code that you use D2 as SlaveSelect/ChipSelect gpio. In Ethernet code, we have:
Frequency in ethernet is initialized once. Maybe you should try and lower your TFT SPI frequency initialization (27->14?). Anyway
|
@d-a-v , Ethernet library uses SPI transactions and applies the settings before every use of the bus |
@JAndrassy ah right !
|
Thank you both, the author of TFT-espi provided good feedback here: Bodmer/TFT_eSPI#811 |
You may add some |
#6680 is merged and Ethernet is now a submodule. Closing this as I believe all is fixed and 2 months w/o updates. |
Basic Infos
Platform
Settings in IDE
Problem Description
I am facing an issue with trying to implement a WP5500 an ESP12 module
The business case is that I need a very small scale device having both WIFI and ethernet connectity because of mechanical and other constraints.
As far as I know I should use the the Ethernet library from Arduinom which I tried.
However looks like the implementation of this library for the ESP8266 is a bit behind other board as it does't allow to for instance use CS pin (using init method) and lacks a few other method like EthernetLinkStatus
Configuration as following:
D0 GPIO16 4
D1 GPIO5 20
D2 GPIO4 19 CS
D3 GPIO0 18
D4 DGPIO2 19
D5 GPIO14 5 SCLK
D6 CPIO12 6 MISO
D7 GPIO13 7 MOSI
D8 GPIO15 16
I kept D5,D6,D7 as the standard SPI config (https://arduino-esp8266.readthedocs.io/en/latest/libraries.html#spi) and only use D2 as CS
Header of ethernet.h from last github repo: https://github.com/arduino-libraries/Ethernet
static int maintain();
static EthernetLinkStatus linkStatus();
static EthernetHardwareStatus hardwareStatus();
Header of ethernet.h from ESP8266 board (for arduino IDE 1.5):
only:
void begin(...);
int maintain();
IPAddress localIP();
IPAddress subnetMask();
IPAddress gatewayIP();
IPAddress dnsServerIP();
I tried to :
use the ESP8266 native library from the package "as is" but the program is just pending at
if (Ethernet.begin(mac) == 0)
and never continues...(no reset no errors)
force usage of the most recent library but when compiling I get followinging error message. I could try to but I am a bit afraid that by doing that I will pull a things that will never end:
W5100.setSubnetMask(subnet._address.bytes);
MCVE Sketch
Debug Messages
no messages
Debug messages go here
The text was updated successfully, but these errors were encountered: