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 0x001Fvoid 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;}