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.
4.
Wait for the BSY bit to be reset.
5.
Read all the pages and verify.
Figure 4.
Option byte programming
The option bytes are programmed differently from normal user addresses. The number of
option bytes is limited to 6 (2 for write protection, 1 for read protection, 1 for hardware
configuration and 2 free bytes for user data). After unlocking the Flash access, the user has
to authorize the programming of the option bytes by writing the same set of KEYS (KEY1
and KEY2) to the FLASH_OPTKEYR register to set the OPTWRE bit in the FLASH_CR
register (refer to
OPTPG bit in the FLASH_CR register and perform a half-word write operation at the desired
Flash address.
48/742
Flash memory Mass Erase procedure
Read LOCK bit in
FLASH_CR
LOCK bit in FLASH_CR
=1
No
Write MER bit
in FLASH_CR to 1
Write STRT bit in FLASH_CR
to 1
BSY bit in
FLASH_SR
=1
No
Check the erase operation by
reading all the addresses in
the user memory
Unlocking the Flash memory
Doc ID 018940 Rev 1
Yes
Perform unlock sequency
Yes
for key values). Then the user has to set the
RM0091
MS19222V1
Need help?
Do you have a question about the STM32F05 series and is the answer not in the manual?
Questions and answers