Skip to content

SPI default clock rate on RP2040 boards is slower than Arduino API Standard. #245

@WestfW

Description

@WestfW

The RP2040 implementation of SPI has (in the relevant SPI.h):

class MbedSPI : public SPIClass
{
   :
private:
    SPISettings settings = SPISettings(0, MSBFIRST, SPI_MODE0);
   : 

where "0" is the bitrate. Presumably, at some point this is converted to the default SPI clock rate for mBed, buried deep inside the mBed code, and it becomes about 1MHz. However, I think it should be just:

    SPISettings settings = SPISettings();

or perhaps

   SPISettings = DEFAULT_SPI_SETTINGS;

(both of which come from API/HardwareSPI.h, and defined a default bitrate of 4MHz.)

With the current code, the default SPI bitrate for RP2040 based boards is one quarter of the speed that it is on an AVR.

A possible workaround, and to get higher speeds, is for uses to provide their own SPI settings:

SPISettings mySPIsettings = SPISettings(10000000, MSBFIRST, SPI_MODE0);  //10MHz
SPI.beginTransaction(mySPIsettings);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions