Go Down

Topic: Using mem shield flash as a replacement for eeprom (Read 724 times) previous topic - next topic

endrew

Hi, I'm trying to read and write a single byte to flash. I am using the following code:
Code: [Select]
#include <SerialFlash.h>
#include <SD.h>
#include <SPI.h>

unsigned char buf[1], sig[1];
unsigned long address;

void setup() {
  // put your setup code here, to run once:
 
  Serial.begin(9600);
  while (!Serial) ;
  delay(100);
  Serial.print("SerialFlash.begin ");
  Serial.println (SerialFlash.begin(5));
  address = 100;
  sig[0] = 15;
  digitalWrite (5,LOW);

}
void loop() {
  sig[0]++;
  digitalWrite (5,LOW);
  SerialFlash.write(address, &sig[0], 1);
  while (!SerialFlash.ready());
  SerialFlash.read(address, &buf[0], 1);
  Serial.print(sig[0]);
  Serial.print(" ");
  Serial.println(buf[0]);
  delay(300);
}


on a mkr wifi 1010, and it doesn't work. I can write only once, and I also see some erratic behavior. Is it possible to write and read a single byte without using files? If so, what am I doing wrong?

Thanks!!

Go Up