user26000: I'm working on a program with Arduino Uno which involves writing and reading EEPROM. I'm using a basic EEPROM library. My problem is: EEPROM values are preset to 255 whenever I burn my program. And there is nothing in my code which will write 255 in these bytes. 
I even tried EEPROM_read example from the EEPROM library and got same result. I used EEPROM_clear code before EEPROM_read to set all values to 0. But when I read those values using EEPROM_read, they are 255. 
Please help explain what is happening.

user6372: You need to set EESAVE fuse
When the ATmega chip is programmed the memory is erased just before the new code is uploaded. Under normal circumstances the eeprom memory is erased as well as the program memory. The EESAVE fuse can be used to tell the chip not to erase the eeprom. This is useful when you want to upgrade code but keep user settings that are stored in eeprom.
The default value is EESAVE=1, not set and eeprom memory is erased during the chip erase cycle when programming.
This fuse calculator is quite handy.

user4143: In flash and eeprom memory an erased value is 255. It's all about how flash memory works. If you want something other than 255 in there you will have to write something other than 255 in there.

26000: <p>I'm working on a program with Arduino Uno which involves writing and reading EEPROM. I'm using a basic EEPROM library. My problem is: EEPROM values are preset to 255 whenever I burn my program. And there is nothing in my code which will write 255 in these bytes. </p>

<p>I even tried <code>EEPROM_read</code> example from the EEPROM library and got same result. I used <code>EEPROM_clear</code> code before <code>EEPROM_read</code> to set all values to 0. But when I read those values using <code>EEPROM_read</code>, they are 255. </p>

<p>Please help explain what is happening.</p>
 6372: <p><strong>You need to set EESAVE fuse</strong></p>

<p>When the ATmega chip is programmed the memory is erased just before the new code is uploaded. Under normal circumstances the eeprom memory is erased as well as the program memory. The EESAVE fuse can be used to tell the chip not to erase the eeprom. This is useful when you want to upgrade code but keep user settings that are stored in eeprom.</p>

<p>The default value is EESAVE=1, not set and eeprom memory is erased during the chip erase cycle when programming.</p>

<p>This <a href="http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p" rel="nofollow">fuse calculator</a> is quite handy.</p>
 4143: <p>In flash and eeprom memory an erased value is 255. It's all about how flash memory works. If you want something other than 255 in there you will have to write something other than 255 in there.</p>
