Platformio not finding default SPI pins on Rpi Pico

My code / project interfaces a Rpi Pico to a ST7789 display via Adafruit’s ST7789.h lib. In the Arduinio IDE this works with no issues. In PlatformIO there is a problem as the same code does not find/use the default SPI pins and the display does nothing. The Adafruit ST7789 lib can be configured for software SPI and when this is given the default Pico SPI pins, it works OK in PlatformIO, but is very slow. Checking C:\Users\Michael.platformio\packages\framework-arduino-mbed\variants\RASPBERRY_PI_PICO\pins_arduino.h the pins are set correctly to the default 2040 SPI pins. I am not sure where the Adfruit SR7789 lib gets the default SPI pin info from, but susspect in the Ardunio IDE it reads C:\Users\Michael\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\2.0.1\variants\rpipico\pins_arduino.h which also shows the pins correctly.
Has anyone experience or a fix for this issue?

Can you show a minimal platformio.ini and code that prints the SPI pin numbers and compare that sketch output to when its uploaded using the Arduino IDE?

Which exact configuration (Tools menu) and core version (pico / mbed core versio in Arduino IDE board manager) are you using?

How do I find - “Which exact configuration (Tools menu) and core version (pico / mbed core version in Arduino IDE board manager) are you using” ?

Rest of info is below.

My PlatformIO ini is…
[env:pico]
platform = raspberrypi
board = pico
framework = arduino
lib_deps =
adafruit/Adafruit GFX Library@^1.11.1
adafruit/Adafruit ST7735 and ST7789 Library@^1.9.3
lib_archive = no


The code for SPI on PlatformIO is below, note this uses software SPI function call.

#include <Arduino.h>
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_I2CDevice.h>
#define TFT_BL 20 // take high for full brightness
#define TFT_CS 17 // useed with spi sd card?
#define TFT_RST -1 // not connected
#define TFT_DC 16 // not sure
#define TFT_MOSI 19 // Data out
#define TFT_SCLK 18 // Clock out

// OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique
// to each board and not reassignable. For Arduino Uno: MOSI = pin 11 and
// SCLK = pin 13. This is the fastest mode of operation and is required if
// using the breakout board’s microSD card.
//Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.

Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);


The code for SPI on Arduinio IDE is below, basically the same as Platformio but uses the
default hardware SPI pins

#include <Arduino.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#include <Adafruit_I2CDevice.h>
#define TFT_BL 20 // take high for full brightness
#define TFT_CS 17 // useed with spi sd card?
#define TFT_RST -1 // not connected
#define TFT_DC 16 // not sure

// OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique
// to each board and not reassignable. For Arduino Uno: MOSI = pin 11 and
// SCLK = pin 13. This is the fastest mode of operation and is required if
// using the breakout board’s microSD card.
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
//#define TFT_MOSI 25 // Data out
//#define TFT_SCLK 24 // Clock out
//Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);


Maxgerhardt, any ideas what I can try to get the display using SPI working?

I mean

grafik

grafik

In Arduino IDE and under Boards Manager, when MBED OS RP 2040 boards and Paspeberry Pi Pico is selcted, the display does not work. But instead for MBED, when I select Raspberry Pi Pico/RP2040 and Generic 2040 it works, also when select Raspberry Pi Pico/RP2040 and Rasberry Pi Pico it work OK. I have MBED installed for the Pico.

In PlatformIO, without any modifications, using board = pico and framework = arduino means the mbed core is selected.

Could you try and follow Using this core with PlatformIO — Arduino-Pico 2.7.1 documentation to get PlatformIO to use the Arduino-Pico (earlephilhower) core?

Thank you Maxgerhartdt, Earlephillower core fixed the display issue and it runs much faster than it did using Ardunio IDE. Now I can also try dual CPU cores also supported by the Earlephillower core. Hope you can make this a fully supported core soon.

1 Like