Accessing SAMD51 Processor's Flash

Hi folks,

Trying to figure out how to properly make use of the 1MB Flash onboard the SAMD51 Processor with a MicroMod Data Logging Carrier Board.

Based on the schematic, the Flash is making use of SPI1. However, the [Hookup Guide does not list which pins SPI1 corresponds to in the pinout table.

Digging into the datasheet and SparkFun board definition, the SPI CS1 is connected to PA11, which is physical pin 20, but in the variant.h board definition file, CS1 is defined as 52, PIN_SPI1_SS or SS1.

//-------------------------------------------

// SPI Interfaces
//-------------------------------------------
#define SPI_INTERFACES_COUNT 2
  
#define PIN_SPI_MOSI         (45u)
#define PIN_SPI_SCK          (46u)
#define PIN_SPI_MISO         (47u)
#define PIN_SPI_SS           (48u)
#define PERIPH_SPI           sercom0
#define PAD_SPI_TX           SPI_PAD_0_SCK_1
#define PAD_SPI_RX           SERCOM_RX_PAD_2

static const uint8_t SS	  = PIN_SPI_SS ;
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK  = PIN_SPI_SCK ;  

// SPI1
#define PIN_SPI1_MOSI         (49u)
#define PIN_SPI1_SCK          (50u)
#define PIN_SPI1_MISO         (51u)
#define PIN_SPI1_SS           (52u)
#define PERIPH_SPI1           sercom2
#define PAD_SPI1_TX           SPI_PAD_0_SCK_1
#define PAD_SPI1_RX           SERCOM_RX_PAD_2
//-------------------------------------------

static const uint8_t SS1	 = PIN_SPI1_SS ; 	
static const uint8_t MOSI1 = PIN_SPI1_MOSI ;
static const uint8_t MISO1 = PIN_SPI1_MISO ;
static const uint8_t SCK1  = PIN_SPI1_SCK ;

Running the SPIMemory library example [“Flash Diagnostics” using SPI1 doesn’t seem to work with any of the following combinations:

SPIFlash flash(SS1, &SPI1);
SPIFlash flash(PIN_SPI1_SS, &SPI1);
SPIFlash flash(52, &SPI1);
SPIFlash flash(20, &SPI1);
12:58:55.484 -> Initialising..........
12:58:55.484 -> 
12:58:55.484 -> SPIMemory Library version: < 2.5.0
12:58:55.484 -> 
12:58:55.484 -> No comms. Check wiring. Is chip supported? If unable to fix, raise an issue on Github

Any guidance would be appreciated!

Cheers,

Adam](SPIMemory/examples/FlashDiagnostics/Diagnostics_functions.ino at master · Marzogh/SPIMemory · GitHub)](https://learn.sparkfun.com/tutorials/micromod-samd51-processor-board-hookup-guide/all)

Oops. I should clarify I’m trying to access the external Winbond 25Q128JVPM 16 MB flash.

The microSD is working fine on the SPI bus but no dice with SPI1.

Cheers,

Adam

The flash chip is tied to the bootloader so it’s not available for general use unless you remove the bootloader and replace it with your own custom firmware.

Hi Chris,

That would explain it!

At least the one good thing that came out of delving into the variant.h file is that I discovered the board definitions were missing definitions for a number of pins.

In terms of power consumption, will the external flash memory usually be in a powered-down state? I’m unfamiliar with how being tied to the bootloader works. I’ve been trying to see what kind of sleep current I can achieve with the SAMD51, but a milliamp or two seems to be the limit (though the SAMD51 can reach 42 uA).

Cheers,

Adam

The flash chip is tied directly to the 3.3 volt rail so it’s always powered but when CS is driven high, the chip does enter a low power state that should be around 20μA.