SPI Compatibility Issues with SAMD21 XIAO and RP2040 XIAO

I’m trying to drive a SPI OLED screen with the RP2040 XIAO. I’ve gotten one of the example projects to work on the SAMD21 XIAO, but the same sample code does not work on the RP2040 XIAO. All I’ve done is removed the SAMD21 XIAO, replaced it with a RP2040 XIAO, and uploaded the same program. I don’t see any obvious pinout differences between the two, especially with regards to SPI.

I’ve looked at the signals on my scope, and it looks like the RP2040 XIAO is just not twiddling the MOSI pin at all. CLK is the only pin that is changing. Is there an issue with the SPI driver on the RP2040 XIAO? I am currently using board version 1.12.0, since 2.7.2 is still having that checksum issue.

If you can tell me your code and the wiring to OLED, I can confirm.

Certainly. I am using the U8G2 library, along with the following pins:
Screen CS: D7
Screen DC: D0
Screen Reset: D3
MOSI: D10 (Hardware SPI MOSI Pin)
MISO: Not connected
CLK: D8 (Hardware SPI CLK Pin)



#include <Arduino.h>
#include <U8g2lib.h>

#include <SPI.h>

U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 0, /* reset=*/ 3);

void setup() {
  pinMode(7, OUTPUT); // Set CS as output
  pinMode(0, OUTPUT); // Set DC as output
  pinMode(3, OUTPUT); // Set reset as output
  u8g2.begin();
}

void loop() {
  u8g2.clearBuffer();
  u8g2_uint_t x, y, w2, h2;
  u8g2.setColorIndex(1);
  w2 = u8g2.getWidth();
  h2 = u8g2.getHeight();
  w2 /= 2;
  h2 /= 2;
  for( y = 0; y < h2; y++ ) {
    for( x = 0; x < w2; x++ ) {
      if ( (x + y) & 1 ) {
        u8g2.drawPixel(x,y);
        u8g2.drawPixel(x,y+h2);
        u8g2.drawPixel(x+w2,y);
        u8g2.drawPixel(x+w2,y+h2);
      }
    }
  }
  u8g2.sendBuffer();
}

Need to correct the pin name
7 → D7
0 → D0
3 → D3

That works. Thank you!