- Fri Mar 23, 2018 9:46 am
#74848
Thanks for your answer, nevertheless it is not so clear for me. Prior to posting this message I had already opened the EEPROM.cpp file and understood that EEPROM.begin(1000000) was still limited inside the function by the SPI_FLASH_SEC_SIZE.
After your comment I read it again and realized there are two class constructors:
EEPROMClass::EEPROMClass(uint32_t sector)
and EEPROMClass::EEPROMClass(void)
I would like to write a simple program to test the EEPROM.
To do this, I need to know how much EEPROM space is left, write a for loop to write inside each byte of the free space and read the EEPROM again to check the content.
Below is what I did before posting my question. Of course it didn't work and I only got 4096 good values, all the rest being 0.
I read the EEPROM.cpp and understood it was limited.
Even after your comment, I still don't know how to use the free EEPROM space at its maximum.
Would you explain it again please?
Thanks,
====================================================
void setup() {
Serial.begin(115200);
while (!Serial) ;
EEPROM.begin(4194304);
}
void loop() {
Serial.print("Flash real size: ");
Serial.println(ESP.getFlashChipRealSize(), DEC);
Serial.println("****** eepromWriting ******");
for (long i=0; i<EEPROM_SIZE; i++){
EEPROM.write(i,170);
yield();
}
EEPROM.commit();
Serial.println("****** eepromReading ******");
for (long index = 0 ; index < EEPROM_SIZE ; index++) {
Serial.print(EEPROM.read(index), HEX);
Serial.print(" ");
if (index%40==0 && index != 0){
Serial.println();
}
yield();
}
}
====================================================