Description
Board
ESP32
Device Description
LAN8720A
Hardware Configuration
No.
Version
v3.2.0
IDE Name
VSCode with PlatformIO
Operating System
Linux
Flash frequency
80MHz
PSRAM enabled
yes
Upload speed
921600
Description
Hi! :) Because of the ESP32 hardware PLL bug, I need to stop using the ESP32 PLL, and will instead connect an external 25 MHz crystal directly to the LAN8720A, as described on Page 29 of their datasheet under "3.7.4.2 REF_CLK Out Mode".
Now I need to tell ESP32 SDK's ETH.begin()
call how to talk to the LAN8720A chip in that configuration.
Can you please provide an example with all the correct values for "ETH.begin" when the ESP32 is connected to a LAN8720A that uses an external 25 MHz crystal on its XTAL1/XTAL2 pins?
PS: It would also be greatly appreciated if someone knows how the ESP32 is able to control/synchronize with the LAN8720A when the crystal is external? Do I need to do something special? Keep in mind that my crystal is only wired to the LAN8720A. It isn't wired to the ESP32. So they are not sharing the same clock. Does anyone know if I need to do something special to turn on/off the crystal via the ESP32 in this configuration, or if the LAN8720A handles it?
What I've researched...
The Ethernet API for the ESP32 SDK is not documented. It only pulls in some example source code, but it doesn't actually explain the APIs or the available constant values:
So I am looking directly at the source code to try to figure out the APIs here:
- https://github.com/espressif/arduino-esp32/blob/release/v3.3.x/libraries/Ethernet/src/ETH.cpp
- https://github.com/espressif/arduino-esp32/blob/release/v3.3.x/libraries/Ethernet/src/ETH.h
But I don't understand what I should do.
The ETH.h contains the following values in an enum:
arduino-esp32/libraries/Ethernet/src/ETH.h
Lines 83 to 88 in a6bba43
I can't find any file where those values (such as ETH_CLOCK_GPIO0_IN
) are defined.
But more importantly, I don't see any way to define an external clock? All those "modes" are only about using GPIO 0/16/17 for PLL clock outputs, which I don't want to do...
I need a way to tell "ETH.begin" that my clock is external.
Then I found this file:
arduino-esp32/libraries/Ethernet/src/ETH.cpp
Lines 222 to 226 in a6bba43
It reveals that there's two secret values: EMAC_CLK_OUT : EMAC_CLK_EXT_IN;
But which value is correct? Why is there an "OUT" and "EXT IN"? None of this seems to be documented anywhere.
Sketch
...
Debug Message
...
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.