Hi there,
So, I have a demo on here “grove Expansion Flash” it is an SPI flash you can add to the bottom of the board, Look at that code demo, has both NRF and ESP versions to clearly see the difference. The trick with the Nordic Nrf52x devices is the SPI interfaces as NRF_SPIM0, NRF_SPIM1, NRF_SPIM2, NRF_SPIM3 for which buss. device mode or method.
ESP32-S3 has the following SPI interfaces:
• SPI0 used by ESP32-S3’s cache and Crypto DMA (EDMA) to access in-package or off-package
flash/PSRAM
• SPI1 used by the CPU to access in-package or off-package flash/PSRAM
• SPI2 is a general purpose SPI controller with its own DMA channel
• SPI3 is a general purpose SPI controller with access to a DMA channel shared between several peripherals
Between the Pin “XLS” sheets for both devices you can look and see which is connected to what.
HTH
GL PJ
I alway find it (the SPI) or the (CS, SS) are not what you think.So I always run a sanity check code to print out what the MCU thinks it is, you see that in the demo as well.
Serial.println("--------------");
Serial.println(SS_SPI0);
Serial.println(MOSI); // master out, slave in
Serial.println(MISO); // master in, slave out
Serial.println(SCK); // clock
Serial.println("--------------");
and here is a snip from the Flash Test Example for a C3 notice the defines.
//static const int spiClk = 40000; // 1 MHz
//#define ALTERNATE_PINS
#ifdef ALTERNATE_PINS
#define VSPI_MISO 9
#define VSPI_MOSI 10
#define VSPI_SCLK 8
#define VSPI_SS 3
#define HSPI_MISO 26
#define HSPI_MOSI 27
#define HSPI_SCLK 25
#define HSPI_SS 32
#else
#define VSPI_MISO MISO
#define VSPI_MOSI MOSI
#define VSPI_SCLK SCK
#define VSPI_SS SS
#define HSPI_MISO 9
#define HSPI_MOSI 10
#define HSPI_SCLK 8
#define HSPI_SS 3
#endif
//uninitalised pointers to SPI objects
SPIClass * fspi = NULL;
SPIClass * hspi = NULL;
//spi = SPIClass(FSPI); // working
SPIClass VSPI (SPI); // Change here to specify the SPI port (HSPI, VSPI, or SPI)
Adafruit_FlashTransport_SPI EflashTransport(SS, &SPI); // Flash Type
Adafruit_SPIFlash Eflash(&EflashTransport);
#define SS 3
void setup() {
Serial.begin(9600);
while (!Serial) delay(2100);
Serial.println();
Serial.println(" Program " __FILE__ " compiled on " __DATE__ " at " __TIME__ );
fspi = new SPIClass(FSPI);
hspi = new SPIClass(HSPI);
pinMode(SS, OUTPUT); // CS for flash
digitalWrite(SS, HIGH); // <-- Set CS pin HIGH to deselect
pinMode(fspi->pinSS(), OUTPUT); //VSPI SS
pinMode(hspi->pinSS(), OUTPUT); //HSPI SS
digitalWrite(SS, HIGH); // <-- Set CS pin HIGH to deselect
Serial.println("--------------");
Serial.println(SS);
Serial.println(MOSI); // master out, slave in
Serial.println(MISO); // master in, slave out
Serial.println(SCK); // clock
Serial.println("--------------");
fspi->begin(VSPI_SCLK, VSPI_MISO, VSPI_MOSI, VSPI_SS); //SCLK, MISO, MOSI, SS
delay(250);
hspi->begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_SS); //SCLK, MISO, MOSI, SS
Serial.println(F("Expansion Flash ID"));
// Initialize ESP32c3 onboard flash library and check its chip ID.