MKR MEM Shield Instruction Guide

Hello all,

I have the Arduino Uno R3, and I am trying to use the on-board Flash memory of the MKR Mem Shield.

So far, I have followed this tutorial: https://www.arduino.cc/en/Guide/MKRMEMShield#pin-usage
And, I use the Paul Stoffregen's SerialFlash library within the code as you can see.

I have the following test code:
//First, please download the SerialFlash library by Paul Stoffregen
#include <SerialFlash.h>
#include <SPI.h>
#include <Keyboard.h>

const int FlashChipSelect = 5; //CS or Chip Select pin

const int f_Length = 256;
const char* fileName = "text.bin";

void setup() {

delay(5000); // 5 seconds

Serial.begin(9600);

Serial.println(" Flash chip testing program " );

//Checking if there is a flashChip connected
if(!SerialFlash.begin(FlashChipSelect)){
Serial.println("Unable to access SPI Flash Chip");
}else{

Serial.println("Flash Chip detected");

}

}

void loop() {
// put your main code here, to run repeatedly:

if(Serial.available() > 0){

char inChar = Serial.read();

if(inChar == 'w'){

Serial.println("Initiating Writing to file");
writeTest(fileName, f_Length);
}

if(inChar == 'r'){
Serial.println("Initiating Reading to file");
readTest(fileName,f_Length);

}
}
}

void writeTest(const char* fileName, int fLength){
//Check if file exists

Serial.println("Checking if file exists.");

if(SerialFlash.exists(fileName)){

Serial.println("FILE EXISTS");
SerialFlash.remove(fileName);

}else{
//File doesn't exists
//Create the file

Serial.println("file doesn't exists");

if(SerialFlash.create(fileName,f_Length)){

Serial.println("Created file, now writing");

SerialFlashFile ff = SerialFlash.open(fileName);
char buf[256] = "Hello World";

ff.write(buf,256);

ff.close();
Serial.println("Done writing to file.");

}else{
Serial.println("Unable to create file");
}
}

}

void readTest(const char* fileName, int fLength){

//Check if file exists
if(SerialFlash.exists(fileName)){

Serial.println("File exists!");

SerialFlashFile file = SerialFlash.open(fileName);

char buffer[256];
file.read(buffer, 256);

Serial.println(buffer);

file.close();
}

}

WHEN I TEST THE CODE, the serial monitor detects Flash when NO PINS are connected.

What am I doing wrong?

I

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.