Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1

ivkac_4155501
New Contributor

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
Expert II

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
Bob_Marlowe
Expert II

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