RM0461
To erase a 2-Kbyte page, follow the steps detailed below:
1.
Check that no flash memory operation is ongoing by checking BSY in FLASH_SR.
2.
Check that flash program and erase operation is allowed by checking PESD in
FLASH_SR.
3.
Check and clear all error programming flags due to a previous programming. If not,
PGSERR is set.
4.
Set PER and select the page to erase (PNB[6:0]) in FLASH_CR.
5.
Set STRT in FLASH_CR.
6.
Wait for BSY to be cleared in FLASH_SR.
Note:
The internal oscillator HSI16 (16 MHz) is enabled automatically when the STRT bit is set,
and disabled automatically when the STRT bit is cleared, except if the HSI16 is previously
enabled with HSION in the RCC_CR register.
Flash mass erase
When PCROP or WRP is enabled, any flash memory mass erase is aborted and no erase
started.
PCROP WRP
No
No
Yes
Yes
To perform a mass erase, follow the steps detailed below:
1.
Check that no flash memory operation is ongoing by checking BSY in FLASH_SR.
2.
Check and clear all error programming flags due to a previous programming. If not,
PGSERR is set.
3.
Set MER in FLASH_CR.
4.
Set STRT in FLASH_CR
5.
Wait for BSY to be cleared in FLASH_SR.
Note:
The internal oscillator HSI16 (16 MHz) is enabled automatically when the STRT bit is set,
and disabled automatically when the STRT bit is cleared, except if the HSI16 is previously
enabled with HSION in the RCC_CR register.
3.3.8
Flash main memory programming sequences
The flash memory is programmed with 72 bits at a time (a double-word of 64 bits plus 8 bits
ECC).
Programming in a previously programmed double-word is only allowed when programming
an all 0 value. It is not allowed to program any other value in a previously programmed
double-word. Any attempt sets PROGERR flag in FLASH_SR, except when programming
an already programmed double-word with an all 0 value.
Table 7. Mass erase overview
PCROP_RDP
No
Memory is erased.
Yes
x
No
Erase aborted (no erase started)
Yes
Comment
RM0461 Rev 5
Embedded flash memory (FLASH)
WRPERR
CPU bus error
No
Yes
No
77/1306
108
Need help?
Do you have a question about the STM32WLEx and is the answer not in the manual?
Questions and answers