ESP32 LAN8720 packet loss in ping

wirahim
Posts: 2
Joined: Sun Jun 20, 2021 10:13 am

ESP32 LAN8720 packet loss in ping

Postby wirahim » Sun Jun 20, 2021 10:34 am

Hello,

Has anyone faced packet loss on LAN8720 if you ping from your computer? I have made an internet clock where I have used both LAN and WiFi of ESP32. Ping seems to work fine for Wi-Fi but there seems to be regular packet loss for the ethernet port.

Loss is typically less than 20%. Here is a sample:
Ping statistics for 192.168.10.189:
Packets: Sent = 602, Received = 512, Lost = 90 (14% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 15ms, Average = 0ms
Although this loss is not an issue for a clock the client is complaining about it.

Here is my configuration for the LAN8720 example code:
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_OUT

// Pin# of the enable signal for the external crystal oscillator (-1 to disable for internal APLL source)
#define ETH_POWER_PIN 17

// Type of the Ethernet PHY (LAN8720 or TLK110)
#define ETH_TYPE ETH_PHY_LAN8720

// I²C-address of Ethernet PHY (0 or 1 for LAN8720, 31 for TLK110)
#define ETH_ADDR 1

// Pin# of the I²C clock signal for the Ethernet PHY
#define ETH_MDC_PIN 23

// Pin# of the I²C IO signal for the Ethernet PHY
#define ETH_MDIO_PIN 18
I have originally followed a tutorial from "https://sautter.com/blog/ethernet-on-es ... g-lan8720/". Internet works fine. I just need to solve the ping issue. Can anyone point me in the direction of a solution?

wirahim
Posts: 2
Joined: Sun Jun 20, 2021 10:13 am

Re: ESP32 LAN8720 packet loss in ping

Postby wirahim » Mon Jun 21, 2021 10:53 am

I found the solution. Code mentioned "possibly an inverter is needed" and I have not used any inverter. So Lan8720's internal clock source was still enabled and it was interfering with APLL's clock.
* ETH_CLOCK_GPIO0_OUT - 50MHz clock from internal APLL output on GPIO0 - possibly an inverter is needed for LAN8720
Solution:

Code: Select all

ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE);
digitalWrite(ETH_POWER_PIN, LOW);
Making the power pin low after ETH.begin solves the problem if I don't use any logic level inverter. I think "possibly an inverter is needed" should be changed to "an inverter is needed".

Anyone who is reading this post, I hope this helps.

Who is online

Users browsing this forum: No registered users and 69 guests