0

I want the eeprom to be initialized with certain values but its not working as intended. What am I doing wrong:

From my .icf File in IAR

define symbol __region_EEPROM_start__ = 0x08080030;
define symbol __region_EEPROM_end__ = 0x080807FF;
..
define region EEPROM_region = mem:[from __region_EEPROM_start__ to __region_EEPROM_end__];
..
place in EEPROM_region  {rw section .eeprom};

In my Code:

__root char dataE[] @ ".eeprom" = {0xFF};
int
main (void)
{

  init ()

yet the eeprom does not get initialized correctly, all I get in debug mode is:

0x08080000 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x08080010 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x08080020 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x08080030 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Cœur
  • 37,241
  • 25
  • 195
  • 267
Flying Swissman
  • 818
  • 2
  • 14
  • 39
  • 1
    I'd be surprised if writing to EEPROM is that easy. If it was so easy, it would not be very secure/useful:( – Martin James Mar 21 '16 at 13:32
  • I'm initalizing it to a value not writing. So it should just put a line in my .hex file at the right address, its just flash.. This is not a problem at runtime, its a problem when writing firmware. – Flying Swissman Mar 21 '16 at 13:36
  • Do you use `dataE` anywhere in the code? If not, then linker won't include it, [unless you tell it to do so](http://stackoverflow.com/a/35983699/694733). – user694733 Mar 21 '16 at 15:55

1 Answers1

0

The EEPROM can be initialized to zero by default by compiler. To initialize to a different value you will have to write it separately and then load it. OR do it in the main in the initialization section.

Puru
  • 1