How to Reserve EEPROM space on Feather RP2040?

As you know, traditional EEPROM does not work on feather, so I found the EEPROM.begin(512) command on some documentation.
The function worked well as long as the rest of the sketch was empty.
However this is a Feather with DVI. As I added the video code to the board I got in trouble.
It all looks great until I write to eeprom. Then the screen goes blank.
If I re-boot it is still blank. No video. However I can read the EEPROM and see it on serial monitor.
I need to re-upload the whole sketch. And then I can't write anything.

Here is the code

#include <EEPROM.h>

// the current address in the EEPROM (i.e. which byte
// we're going to write to next)
int addr = 0;
unsigned long PrintTimer = 0;
int FromEnc;
int valueBack;

void setup() {
  Serial.begin(115200);
  EEPROM.begin(512);
}

void loop() {
  // need to divide by 4 because analog inputs range from
  // 0 to 1023 and each byte of the EEPROM can only hold a
  // value from 0 to 255.
  int val = 155;// analogRead(A0) / 4;

  // write the value to the appropriate byte of the EEPROM.
  // these values will remain there when the board is
  // turned off.
  EEPROM.put(addr, 86400);

  // advance to the next address.  there are 512 bytes in
  // the EEPROM, so go back to 0 when we hit 512.
  // save all changes to the flash.
  addr = addr + 1;
  if (addr == 512) {
    addr = 0;
    if (EEPROM.commit()) {
      //Serial.println("EEPROM successfully committed");
    } else {
      //Serial.println("ERROR! EEPROM commit failed");
    }
  }

  if (millis() - PrintTimer >= 1000)
  { PrintTimer = millis();
 

    //Get the float data from the EEPROM at position 'eeAddress'
   EEPROM.get(addr, valueBack);
   Serial.println( valueBack );  //This may print 'ovf, nan' if the data inside the EEPROM is not a valid float.
  }
 // delay(100);
}

86400 is an unusual value to store in a byte.

Im using several addresses to store large numbers.
Even if I store number 1, the video code is ruined

512 such large numbers, in 512 bytes? That is what the loop does:

  addr = addr + 1;
  if (addr == 512) {
    addr = 0;

Post a link to the actual library you are using, so forum members can judge whether it is being used correctly (hint: it isn't).

512 is for large numbers

I have tired to limit it to 8 but its the same result, Crash.

if (WriteOnce==true)
{
  EEPROM.put(addr, val);

    addr = addr + 4;
    if (addr == 8) {
    addr = 0;
    if (EEPROM.commit()) {
      Serial.println("EEPROM successfully committed");
      WriteOnce=false;
    } else {
      Serial.println("ERROR! EEPROM commit failed");
    }
    }
}

Here are the libraries for this board

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