Skip to main content
MNowa.8
Visitor II
Jun 7, 2023 11:00 AM UTC
Question

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

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

This topic has been closed for replies.

2 replies

Douglas MILLER
ST Employee
Dec 19, 2023 8:08 AM UTC

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
Super User
Dec 19, 2023 7:30 PM UTC

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.