Embedded flash memory
Mass erase
The Mass erase command can be used to completely erase the user pages of the flash
memory. The information block is unaffected by this procedure. The following sequence is
recommended:
1.
Check that no flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register
2.
Set the MER bit in the FLASH_CR register
3.
Set the STRT bit in the FLASH_CR register (see below note)
4.
Wait for the BSY bit to be reset
5.
Check the EOP flag in the FLASH_SR register (it is set when the erase operation has
succeeded), and then clear it by software.
6.
Clear the EOP flag.
Note:
The software must start checking if the BSY bit equals '0' at least one CPU cycle after
setting the STRT bit.
52/874
Figure 3. Flash memory Page Erase procedure
Read FLASH_CR_LOCK
FLASH_CR_LOCK
= 1
No
Write FLASH_CR_PER to 1
Write into FAR an address
within the page to erase
Write FLASH_CR_STRT to 1
FLASH_SR_BSY
= 0
Yes
Check EOP flag in
FLASH_SR, and then
clear it by software.
RM0366 Rev 5
Yes
Perform unlock sequency
No
RM0366
Need help?
Do you have a question about the STM32F301 6 Series and is the answer not in the manual?