cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723 Flash Erasing before writing

adakPal
Associate

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.

2 REPLIES 2

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

SofLit
ST Employee

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 on "Accept as Solution" on the reply which solved your issue or answered your question.