Skip to main content
Graduate
November 28, 2024
Solved

STM32H723 Flash Erasing before writing

  • November 28, 2024
  • 2 replies
  • 834 views

Hi STM Community, 

I want to ask if I have to Erase Flash memory sector  (HAL_FLASHEx_Erase) before I write into flash memory (HAL_FLASH_Program)?

I tried it and nothing happend. I want to be sure, that is not an accident.

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello, As said by @Andrew Neil this is the nature of the NOR Flash memory:

    From the reference manual:

    SofLit_1-1732791455067.png

     

    SofLit_0-1732791381499.png

    You can inspire from this example provided in STM32H7 Cube HAL:

    https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Projects/STM32H743I-EVAL/Examples/FLASH/FLASH_EraseProgram/Src/main.c

    See also this video on how a generic NOR flash memory is working: https://www.youtube.com/watch?v=V1JdpqvUIhk

    2 replies

    Super User
    November 28, 2024

    Yes - that is the nature of Flash.

    In STM32, you probably have to unlock before you can erase or write - check the chip's Reference Manual, and/or the HAL documentation ...

    mƎALLEmAnswer
    Technical Moderator
    November 28, 2024

    Hello, As said by @Andrew Neil this is the nature of the NOR Flash memory:

    From the reference manual:

    SofLit_1-1732791455067.png

     

    SofLit_0-1732791381499.png

    You can inspire from this example provided in STM32H7 Cube HAL:

    https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Projects/STM32H743I-EVAL/Examples/FLASH/FLASH_EraseProgram/Src/main.c

    See also this video on how a generic NOR flash memory is working: https://www.youtube.com/watch?v=V1JdpqvUIhk