How to count write cycles in eeprom.

Hello.

For EEPROM, specify in Mega2560.

The lifecycle prediction is done by each cell, or throughout the eeprom.

For example…
My routine below will write a string of 50 chars. One in each address starting from 0x0.

for (uint8_t i=0; i<50; ++i){
while(EECR & (1<<EEPE)); /* Wait for completion of previous write */
EEPROM.write(0x0+i, ipsvr.charAt(i));
}

In lifecycle of EEPROM, this operation counts as 1 or 50???

It would be 1 recording in each cell, but in total there are 50 operations.

Thank You…

Marcio Lima.

1, because it's the lifetime cycle of each cell.

PS, why the messing with registers? The EEPROM library already takes care of that... PPS You're not using a string, you use a String ;) PPPS And easy way to save write, use EEPROM.update()

Thank´s septillion…

Im´s using te instruction

"while(EECR & (1<<EEPE)); "

because the datasheet recomendation.

I look the EEPROM.h library and did not find a similar instruction, so I inserted it for precaution. :wink:

About EEPROM.udate(), good idea, I will use.

martlima: because the datasheet recomendation.

But did the datasheet also recommended to use the EEPROM library? Aka, it's a bad idea to mix and match register manipulation and a higher level library to do the job unless you know exactly what you do. Not "just for precaution". It's like putting oil into you car because you didn't saw the mechanic do it (because you coudn't find a dipstick). Here you might be alright (but don't need to) but in other cases you can simply break the library...

So or stick to the library or drop the library and read the registers yourself like the datasheet tells you. :D