There is a issuse: After esp32 run,blocking at。
Code: Select all
while (!((uint32_t)ETH.localIP()))
{
}
Serial1 print :
Code: Select all
11:11:22.438 -> rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
11:11:22.438 -> configsip: 0, SPIWP:0xee
11:11:22.438 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
11:11:22.438 -> mode:DIO, clock div:2
11:11:22.438 -> load:0x3fff0030,len:1184
11:11:22.438 -> load:0x40078000,len:12784
11:11:22.438 -> load:0x40080400,len:3032
11:11:22.438 -> entry 0x400805e4
11:11:22.741 ->
11:11:22.741 -> Start
11:11:22.741 ->
GPIO :ETH_CLOCK_GPIO0_IN can get 50MHz from lan8702a.
Lan8720 can ouput 1.2V.
Hardware:esp32_wroom_32u + lan8720a
platform io
- framework-arduinoespressif32 @ 3.20003.220626 (2.0.3)
Dependency Graph
|-- Ethernet @ 2.0.0
| |-- WiFi @ 2.0.0
|-- WiFi @ 2.0.0
Code: Select all
#ifdef ETH_CLK_MODE
#undef ETH_CLK_MODE
#endif
#define ETH_NRST 17
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN//ETH_CLOCK_GPIO17_OUT
// Pin# of the enable signal for the external crystal oscillator (-1 to disable for internal APLL source)
#define ETH_POWER_PIN -1
// 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//15
// Pin# of the I²C IO signal for the Ethernet PHY
#define ETH_MDIO_PIN 18//2
#include <Arduino.h>
#include <ETH.h>
#include <WiFiUdp.h>
WiFiUDP Udp;
unsigned int localUdpPort = 2333;
void printETHInfo(void)
{
Serial.print("ETH MAC: ");
Serial.print(ETH.macAddress());
Serial.print(", IPv4: ");
Serial.print(ETH.localIP());
if (ETH.fullDuplex())
{
Serial.print(", FULL_DUPLEX");
}
Serial.print(", ");
Serial.print(ETH.linkSpeed());
Serial.println("Mbps");
}
void WiFiEvent(WiFiEvent_t event)
{
switch (event)
{
case SYSTEM_EVENT_ETH_START:
Serial.println("ETH Started");
break;
case SYSTEM_EVENT_ETH_CONNECTED:
Serial.println("ETH Connected");
break;
case SYSTEM_EVENT_ETH_GOT_IP:
Serial.println("ETH GOT IP");
printETHInfo();
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
break;
case SYSTEM_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
break;
default:
break;
}
}
void setup()
{
Serial.begin(115200);
Serial.println();
WiFi.onEvent(WiFiEvent);
Serial.println("Start\n");
pinMode(ETH_MDC_PIN, OUTPUT);
pinMode(ETH_NRST, OUTPUT);
digitalWrite(ETH_NRST, 0);
delay(10);
digitalWrite(ETH_NRST, 1);
delay(50);
digitalWrite(ETH_NRST, 0);
delay(50);
digitalWrite(ETH_NRST, 1);
delay(20);
ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE);
while (!((uint32_t)ETH.localIP()))
{
}
Serial.println("Connected");
Serial.print("IP Address:");
Serial.println(ETH.localIP());
Udp.begin(localUdpPort);
}
void loop()
{
int packetSize = Udp.parsePacket();
if (packetSize)
{
char buf[packetSize];
Udp.read(buf, packetSize);
Serial.println();
Serial.print("Received: ");
Serial.println(buf);
Serial.print("From IP: ");
Serial.println(Udp.remoteIP());
Serial.print("From Port: ");
Serial.println(Udp.remotePort());
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.print("Received: ");
Udp.write((const uint8_t*)buf, packetSize);
Udp.endPacket();
}
}