Changing Ethernet SPI pins

Hi, I am using pico with W5500. I was using ArduinoCore-mbed core , so I used these pins.

W5500 <---> RP2040
MOSI <---> GP3
MISO <---> GP4
SCK <---> GP2
SS <---> GP5
GND <---> GND
VCC <---> +3.3V

Now ,I moved on Earle Philhower's arduino-pico core but I have to use pins same as Arduinocore-mbed core.

Earle Philhower's arduino-pico core

2.1 SPI0 (default)

W5500 <---> RP2040
MOSI <---> GP19
MISO <---> GP16
SCK <---> GP18
SS <---> GP17
GND <---> GND
VCC <---> +3.3V

Not these pins.

I have pcb for first connections (It is only pin header PCB) so I have to use

MOSI|<--->|GP3| , |MISO|<--->|GP4|, |SCK|<--->|GP2| , |SS|<--->|GP5|. How can I change these pins?

I took connections from this post arduinoforum .

I probably need to change these pins githublink but I don't know how can I find it. I am using macOS.

The default SPI library of the mbed core uses the same pins for the standard SPI interface (16-19). Which Ethernet library did you use? Did you explicitly define these pins?

I used these pins with this library githublink . I try to define SPI pins from sketch like this ;

#define PIN_SPI0_MISO  (4u)
#define PIN_SPI0_MOSI  (3u)
#define PIN_SPI0_SCK   (2u)
#define PIN_SPI0_SS    (17u)

but it didn't worked. I have to use W5500 with this pins but when I use Earle Philhower's arduino-pico core, I can only use these pins.

// SPI
#define PIN_SPI0_MISO  (16u)
#define PIN_SPI0_MOSI  (19u)
#define PIN_SPI0_SCK   (18u)
#define PIN_SPI0_SS    (17u)

#define PIN_SPI1_MISO  (12u)
#define PIN_SPI1_MOSI  (15u)
#define PIN_SPI1_SCK   (14u)
#define PIN_SPI1_SS    (13u)

Maybe Earle Philhower's arduino-pico core hard coded SPI pins. (I don't really expert I coldn't figure it out)
How can I use GP2,GP3,GP4 pins instead of 16-19 or 12-15 ?

The SPI pins have been modified from core ArduinoCore-mbed v2.7.2 from

// SPI
#define PIN_SPI_MISO  (4u)
#define PIN_SPI_MOSI  (3u)
#define PIN_SPI_SCK   (2u)
#define PIN_SPI_SS    (5u)

to new breaking definitions

// SPI
#define PIN_SPI_MISO  (16u)
#define PIN_SPI_MOSI  (19u)
#define PIN_SPI_SCK   (18u)
#define PIN_SPI_SS    (17u)

That's why you got into the issue

You'd better change the connections to the latest core, to be compatible for both RP2040 cores.

The other unadvised and temporary solutions are

  1. Use the old core ArduinoCore-mbed v2.6.1
  2. Use the latest core and modify the line

back to

// SPI
#define PIN_SPI_MISO  (4u)
#define PIN_SPI_MOSI  (3u)
#define PIN_SPI_SCK   (2u)
#define PIN_SPI_SS    (5u)

I am sorry, as I say I am lack of code knowledge. I want to use Earle Philhower's arduino-pico core with

|W5500|<--->|RP2040|
|MOSI|<--->|GP3|
|MISO|<--->|GP4|
|SCK|<--->|GP2|
|SS|<--->|GP5|
|GND|<--->|GND|
|VCC|<--->|+3.3V| 

these pins. If I did what you tell me, is it possible to use with these pins ?

(I am really sorry for this noob questions)

Sorry I miss that you'd like to use arduino-pico core

You can try to modify

  1. SPI0 pins by changing

to

// SPI
#define PIN_SPI_MISO  (4u)
#define PIN_SPI_MOSI  (3u)
#define PIN_SPI_SCK   (2u)
#define PIN_SPI_SS    (5u)
  1. or the better way to keep SPI0 pins intact (for compatibility) and change SPI1 pins from

to

#define PIN_SPI1_MISO  (4u)
#define PIN_SPI1_MOSI  (3u)
#define PIN_SPI1_SCK   (2u)
#define PIN_SPI1_SS    (5u)

then use this AdvancedWebServer_RP2040_SPI1 example to verify, after changing

to

  #if (USING_SPI2)
    // SCK: GPIO2,  MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 for SPI1
    #define USE_THIS_SS_PIN       5

Post issue on the EthernetWebServer if you still have problem.

Thank you, it worked.

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