Does EEPROM data survive upload?

Hi, I suppose I could write a sketch to test this, but someone will know.

Does the data in the EEPROM area survive an upload to the board.

I've got some data (e.g. the number of EEPROM write cycles performed, and ongoing calibration data), that I'd like to maintain between uploads. I'm using an Arduino Nano.

If I make those data fields the first in the struct I declare for EEPROM data, will they get overwritten on upload.

TIA

yes. it's not cleared when you change the code

Yes, if you do the upload in the conventional way using the IDE

Thanks, that's what I thought.

I've got a mechanism for initialising the data, using an "ID" variable which I place last in the structure. I #define an "id" value which can force initialisation if needed, either by changing the EEPROM struct, or by changing the "id" define value. After that, persistent data is needed.

Thanks for the swift replies, guys.

On an AVR (Uno, Nano etc.) the fuse bits control whether or not the EEPROM is cleared on upload of a sketch. The default in the Arduino IDE is to preserve the EEPROM contents.

Ah, not learnt about fuse bits yet, haven't seen the need to, lol.

I'm happy to go with defaults on this project.....

Actually…. Not when you’re using the bootloader. The bootloader doesn’t understand eeprom at all, and doesn’t touch it. Nor does it look at fuses.

OK. Maybe it was a bit loosley worded in that I used the term Arduino IDE to generally refer to an 'Arduinoized' MCU, that is one with the typical Arduino fuse settings and the bootloader etc.

Hopefully this is unambiguous:

The fuse is the EESAVE bit in the high fuse byte. By default it is un-programmed (has the value 1) which means that the contents of the EEPROM are erased when the Chip Erase command is executed, typically when the device enters programming mode. In an 'Arduinoized' MCU, the EESAVE fuse bit is cleared (has the value (0) meaning that the contents of the EEPROM are preserved across programming operations. The initiation of programming mode differs slightly depending on whether the chip is being programmed by a parallel or serial method. See the data sheet chapter "Memory Programming".

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