cancel
Showing results for 
Search instead for 
Did you mean: 

Unexpected Behavior while writting Flash. L433 + CudeIDE + jlink.

MNowa.8
Associate

I am writting unit tests for storing data in Flash. First test pass.

Second test checks page erasing. After erasing first 8 bytes of given page are not cleared. However if I comment line 50 test is passing. Why is this happening ?


_legacyfs_online_stmicro_images_0693W00000dDIqYQAW.png

2 REPLIES 2
Douglas MILLER
ST Employee

This forum thread was marked by the moderator as needing a little more investigation, so a Support case was created in your name and will be handled off-line.

Bob S
Principal

You need to declare the pointer as pointing to "volatile", otherwise the compiler will optimize out the 2nd read from flash in line 52.

uint8_t FirstByteBeforeTest = *(volatile uint8_t *)(FlashTestAddress);

And you do not need the "volatile" on line 52.

Also note that the debugger ALWAYS treats FLASH as unchangeable.  It will not re-read the data after the erase operation.