cancel
Showing results for 
Search instead for 
Did you mean: 

Why It's necessary erase the flash before write in code time?

MRebo.2
Associate II

When we program the any stm32 mcu, we can choice between erase the memory or no in STM32CubeProgrammer. Why in code time we can't write in flash without erasing the memory?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> Why in code time we can't write in flash without erasing the memory?

Because that is a fundamental hardware limitation of FLASH memory.

https://en.wikipedia.org/wiki/Flash_memory#Block_erasure

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

> Why in code time we can't write in flash without erasing the memory?

Because that is a fundamental hardware limitation of FLASH memory.

https://en.wikipedia.org/wiki/Flash_memory#Block_erasure

If you feel a post has answered your question, please click "Accept as Solution".

Which STM32?

> Why in code time we can't write in flash without erasing the memory?

You can, but if the FLASH was not erased, the write may/will fail.

The option in CubeProgrammer is for the case that you've erased the FLASH some time before the programming, or you are using a brand new never programmed chip (which is erased from factory).

JW