This code runs, but I can’t get the second EXTERNAL flash with the A1/D1(pin2) as CS
to go or show ? ANy suggestions please? The Adafruit_SPIFlash library is difficult to understand IMO
I can’t seem to get any other SPI’s to go i.e. SPI1 or SPI2 or 3 .
This code works on the External Onboard 2 Meg Flash .
// Adafruit SPI Flash Example
// Author: PJG
//
//----------------------------------------------------------------------------------------------
// BSP : Seeed nRF52 Borads 1.1.1
// Board : Seeed nRF52 Borads / Seeed XIAO nRF52840 Sense
//----------------------------------------------------------------------------------------------
// SdFat - Adafruit [email protected]
// Adafruit [email protected]
//
// Tested AOK onboard External Flash.
// 12/9/2023
#include <SPI.h>
#include <SdFat.h>
#include <Adafruit_SPIFlash.h>
const int chipSelect = 2; // CS pin for Expansionflash on Grove PCboard
#define expFlashCS D1
// Built from the P25Q16H datasheet.
// https://gitlab.com/arduino5184213/seeed_xiao_nrf52840/flash_speedtest/-/tree/master
SPIFlash_Device_t const P25Q16H {
.total_size = (1UL << 21), // 2MiB
.start_up_time_us = 10000, // Don't know where to find that value
.manufacturer_id = 0x85,
.memory_type = 0x60,
.capacity = 0x15,
.max_clock_speed_mhz = 55,
.quad_enable_bit_mask = 0x02, // Datasheet p. 27
.has_sector_protection = 1, // Datasheet p. 27
.supports_fast_read = 1, // Datasheet p. 29
.supports_qspi = 1, // Obviously
.supports_qspi_writes = 1, // Datasheet p. 41
.write_status_register_split = 1, // Datasheet p. 28
.single_status_byte = 0, // 2 bytes
.is_fram = 0, // Flash Memory
};
Adafruit_FlashTransport_QSPI flashTransport;
Adafruit_SPIFlash flash(&flashTransport);
void setup() {
while (!Serial) delay(2100);
Serial.println(F("SPI Flash ID"));
pinMode(2, OUTPUT); // set CS as output in lew of DNP on board, teting with and with out.
// Initialize flash library and check its chip ID.
if (!flash.begin(&P25Q16H, 1)) {
Serial.println(F("Error, failed to initialize flash chip!"));
while(1) yield();
}
Serial.print(F("Flash chip JEDEC ID: 0x")); Serial.println(flash.getJEDECID(), HEX);
Serial.print(F("Flash size: ")); Serial.print(flash.size() / 1024); Serial.println(F(" KB"));
Serial.println(F("Flash chip successfully ID'd!"));
}
void loop() {
// Nothing to be done in the main loop.
}
here’s the output;
SPI Flash ID
Flash chip JEDEC ID: 0x856015
Flash size: 2048 KB
Flash chip successfully ID'd!
TIA
GL PJ