Issue with Em-EEprom.... again

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ivkac_4155501
Level 1
Level 1

Dear Community,

here we go again.

So I manged to write a code that writes values into the flash but now I am facing a problem that looks very weird to me (bug?).

Flash_mem.PNG

I created a variable in flash "store" (address: 0x000013d8) and intilized it with a value of 2.

Then I wrote using the EEPROM_Write(...) function a new value of 3 in the flash:

Memory_Flash.PNG

Then I tried to read this value into a uint8 variable state (address 0x1fff8168) (it does not work with state=store either):

State.PNG

The problem is; after the first line the state variable contains allways the intializing value (in this case 2) and not what is actually stored under the address  of store (the value under the address 0x000013d8 is still the same (3)).

State_Mem.PNG

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

This behaving is caused by some compiler optimization.. The compiler "remembers"  the initialization value and does not access the newly written value. I overcame problems like that by using memcpy() to retrieve the eeprom data that were set using initialization values.

Bob

View solution in original post

0 Likes
1 Reply