XIAO SPI Speed slower than a UNO

“SPI.h” and “SPI.cpp” are located at

C:\Users\xxxxxxxxxxxx\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.3\libraries\SPI

“SPI.h” should be editable by notepad.exe.
Find and change the following location around line 50.


#if defined(__SAMD51__)
  // SAMD51 has configurable MAX_SPI, else use peripheral clock default.
  // Update: changing MAX_SPI via compiler flags is DEPRECATED, because
  // this affects ALL SPI peripherals including some that should NOT be
  // changed (e.g. anything using SD card). Use the setClockSource()
  // function instead. This is left here for compatibility with interim code.
  #if !defined(MAX_SPI)
    #define MAX_SPI 24000000
  #endif
  #define SPI_MIN_CLOCK_DIVIDER 1
#else
  // The datasheet specifies a typical SPI SCK period (tSCK) of 42 ns,
  // see "Table 36-48. SPI Timing Characteristics and Requirements",
  // which translates into a maximum SPI clock of 23.8 MHz.
  // Conservatively, the divider is set for a 12 MHz maximum SPI clock.
  #if !defined(MAX_SPI)
// ******************************************************************************
//    #define MAX_SPI 12000000
    #define MAX_SPI 24000000	// <--------------------------- modify the value
// ******************************************************************************
  #endif
  #define SPI_MIN_CLOCK_DIVIDER (uint8_t)(1 + ((F_CPU - 1) / MAX_SPI))
#endiftype or paste code here