Skip to main content
Associate II
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.

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

Andrew Neil
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 ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
mƎALLEm
mƎALLEmBest answer
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

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.