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.
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.
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.
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".