Skip to main content
Visitor II
June 7, 2023
Question

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

  • June 7, 2023
  • 2 replies
  • 802 views

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

    ST Employee
    December 19, 2023

    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.

    Super User
    December 19, 2023

    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.