RP2040 Changing SPI pins for ethernet.h does not work

Changing pins of the SPI seems not be working. The code below is the example sketch WebClient given by the IDE (Examples > Ethernet > WebClient) i did remove the contents of the loop as those are unecessary at the moment. As i was investigating what is the cause why im not able to connect the internet, i found that the SPI signals does not look right.

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server(172, 217, 24, 100); // numeric IP for Google (no DNS)

IPAddress ip(192, 168, 1, 177);
IPAddress myDns(192, 168, 1, 1);

EthernetClient client;

unsigned long beginMicros, endMicros;
unsigned long byteCount = 0;
bool printWebData = true;  // set to false for better speed measurement

void setup() {

SPI.setRX(0);
SPI.setTX(3);
SPI.setSCK(2);
SPI.setCS(1);

  Serial.begin(9600);


  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // Check for Ethernet hardware present
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
      while (true) {
        delay(1); // do nothing, no point running without Ethernet hardware
      }
    }
    if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, myDns);
  } else {
    Serial.print("  DHCP assigned IP ");
    Serial.println(Ethernet.localIP());
  }

  
}

void loop() {
}

I have a scope shot of the 4 SPI pins, This is directly taken on the legs of the W5500 module. The Chip select pin seem not to be pulling low, thus the device is not responding.

To verify that it is not hardware base related. I have tried to run it with Arduino Mbed OS RP2040 board v2.5.2. The signals makes much more like a SPI transaction. (Note: i have modified the pin_arduino.h of the Mbed OS to use MOSI=3 , MISO=0, SCLK=2, CS =1 )

Arduino IDE version 1.8.16
Arduino Core - Raspberry Pi RP2040 Boards v 1.9.6 - Raspberry pi pico
Physical Board - Raspberry Pi Pico
Ethernet Module - W5500

You can use my EthernetWebServer library with the SPI as follows:

  1. MBED core
    SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5

  2. E. Philhower's arduino-pico core
    SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17

For example WebClientRepeating

add Ethernet.init(1); // CS pin

I think that helped

Problem is its still not detecting the hardware, tested it on 3 w5500 modules.

RP2040 relies on mbed declaration to change the default pins (change "mySPI" to what you need)... Not sure how this impacts the Ethernet library though :

MbedSPI mySPI(0, 3, 2);

I am not using mbed core sir, the problem im encountering is with E. Philhower's arduino-pico core

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.