I am trying to use the W25Q128JVSIQ Winbond flash chip which is supported by the SPIMemory library and communicate to it with an Arduino Nano 33 BLE which isn't explicitly supported by this library. However, I added
|| defined(ARDUINO_ARCH_NRF52840)
to line 106 of SPIMemory.h which solved the util.delay.h error I was getting when compiling the TestFlash.ino sketch which was suggested by the Arduino Forum in this thread.
The trouble is that after uploading the sketch the microcontroller fails to communicate with the flash chip indicated by error "2" in the Diagnostics of the serial monitor. Chip Select has been set to 1 as I believe TX on the Nano 33 BLE is pin 1.
I have tested continuity with all of the pins on the flash. I expected the sketch to upload and then print the scripts in the setup as well as the commands. The initialization failed with the "2" error indicating a failure to communicate with the chip. After entering "1" into the command line, I expected the JEDECID to be presented. Instead, the JEDECID was represented as zeroes. Before I added the addition to line 106, the serial monitor didn't print the command lines at all. My question is how do I get the arduino to communicate with this chip? I am using SPIMemory version 3.2.0 and Arduino version 1.8.15.
TestFlash.ino:
#include<SPIMemory.h>
uint8_t pageBuffer[256];
String serialCommand;
char printBuffer[128];
uint32_t addr;
uint8_t dataByte;
uint16_t dataInt;
String inputString, outputString;
//Define a flash memory size (if using non-Winbond memory) according to the list in defines.h
//#define CHIPSIZE MB(64)
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
// Required for Serial on Zero based boards
#define Serial SERIAL_PORT_USBVIRTUAL
#endif
#if defined (SIMBLEE)
#define BAUD_RATE 250000
#define RANDPIN 1
#else
#define BAUD_RATE 115200
#if defined(ARCH_STM32)
#define RANDPIN PA0
#else
#define RANDPIN A0
#endif
#endif
SPIFlash flash;
//SPIFlash flash(SS1, &SPI1); //Use this constructor if using an SPI bus other than the default SPI. Only works with chips with more than one hardware SPI bus
void setup() {
Serial.begin(BAUD_RATE);
#if defined (ARDUINO_ARCH_SAMD) || (__AVR_ATmega32U4__) || defined(ARCH_STM32) || defined(NRF5) || defined(ARDUINO_ARCH_NRF52840)
while (!Serial) ; // Wait for Serial monitor to open
#endif
delay(50); //Time to terminal get connected
Serial.print(F("Initialising"));
for (uint8_t i = 0; i < 10; ++i)
{
Serial.print(F("."));
}
Serial.println();
randomSeed(analogRead(RANDPIN));
flash.begin();
//To use a custom flash memory size (if using memory from manufacturers not officially supported by the library) - declare a size variable according to the list in defines.h
//flash.begin(MB(64));
Serial.println(flash.error());
Serial.println();
Serial.println();
commandList();
}