| FORUM

FEDEVEL
Platform forum

USE DISCOUNT CODE
EXPERT30
TO SAVE $30 USD

Plz help - Custom W5500 Ethernet Module SPI issue with ESP32

Induranga Randika , 12-25-2024, 09:35 PM
Hello community,

I have designed a PCB which has the ESP32 S3 as the main MCU and made a custom W5500 circuitry for LAN connection for MODBUS communication purpose.

I needed to check the SPI communication between the esp32 and the w5500 chip first and i wrote a code to check the chip id of the w5500 and it return wromng value. I tried several methods and concluded that spi in not working for some reason. As 1st version of this PCB, My PCB was 2 layer and i suspected having not a proper gnd below spi is the issue and designed the v2 of the PCB in 4 layer and make the connection very shorter and use a solid gnd plane in 2nd layer.

I tried the same code again and according to the code, SPI is not working. I reduced the SPI clk speed and rechecked but had no luck. Now I am sick of this. The PCB was well designed for the W5500 circuitry, I follwed the reference schematic and layout guide.

if someone has worked with this W5500 chip please suggest me a fix ?

What could be the issue. ?

The chip is also authentic.

Here is the routing between ESP32 and W5500 SPI connections are rounded by yellow circles in the image. (RST line is 4th layer and it is not visible in this image and it also connected to esp32 with a pull up.)

Am I missing something ?
Induranga Randika , 12-25-2024, 09:36 PM
I also used proper series termination for SCLK, MOSI and MISO.
Induranga Randika , 12-25-2024, 09:42 PM
here is the used code in Arduino IDE

#include

// W5500 Ethernet shield pin definitions
#define PIN_SCSN 14
#define PIN_RESET 21

// W5500 version register
#define W5500_VERSION_REG 0x001F

void setup() {
// Initialize Serial Monitor
Serial.begin(115200);

// Setup SPI
SPI.begin(13, 12, 11, PIN_SCSN); // SCLK, MISO, MOSI, SS
pinMode(PIN_RESET, OUTPUT);

// Set SPI settings: mode 0, MSB first, 8 MHz clock speed
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));

// Reset the W5500 (active low)
digitalWrite(PIN_RESET, LOW);
delay(10);
digitalWrite(PIN_RESET, HIGH);
delay(10);

// Read the W5500 version register
byte version = readW5500Register(W5500_VERSION_REG);
Serial.print("W5500 Version: ");
Serial.println(version, HEX);

// Check if the version is correct (should be 0x04 for W5500)
if (version == 0x04) {
Serial.println("SPI communication with W5500 is successful!");
} else {
Serial.println("SPI communication with W5500 failed!");
}

// End SPI transaction
SPI.endTransaction();
}

void loop() {
// In the loop, you can add more tests or checks if needed
}

byte readW5500Register(uint16_t address) {
byte result;

// Select the W5500 (active low)
digitalWrite(PIN_SCSN, LOW);

// Send the address and control byte to read
SPI.transfer(highByte(address));
SPI.transfer(lowByte(address));
SPI.transfer(0x00); // Control byte for read operation

// Read the result
result = SPI.transfer(0x00);

// Deselect the W5500 (active low)
digitalWrite(PIN_SCSN, HIGH);

return result;
}
Induranga Randika , 12-25-2024, 09:52 PM
@Robert Feranec @QDrives @Phil
QDrives , 12-25-2024, 11:25 PM
What do you read?
Have you checked the signals with an oscilloscope?
Do you have series termination resistors or is there something else on the lines?
Induranga Randika , 12-25-2024, 11:50 PM
As mentioned above, i used series termination
Robert Feranec , 12-26-2024, 04:30 PM
I have exactly the same question as @QDrives ... probe the signals by a scope or logic analyzer and read what exactly is on the bus. Is it the same as what you are sending / reading?
Use our interactive Discord forum to reply or ask new questions.
Discord invite
Discord forum link (after invitation)

Didn't find what you were looking for?