2023-06-07 04:00 AM - edited 2023-11-20 03:45 AM
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 ?
2023-12-19 12:08 AM
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.
2023-12-19 11:30 AM
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.