Embedded flash memory (FLASH)
Note:
FLASH_CR and FLASH_C2CR cannot be written when BSY is set respectively in
FLASH_SR or FLASH_C2SR. Any attempt to write to these registers with BSY set causes
the AHB bus to stall until BSY is cleared.
4.3.7
Flash main memory erase sequences
The flash memory erase operation can be performed at page level (page erase) or on the
whole memory (mass erase). Mass erase does not affect the information block (system
flash memory, OTP and option bytes).
Flash memory page erase
The CPU1 is only able to page erase the non-secure part of the user flash memory.
The secure CPU2 is able to page erase both the secure and non-secure parts of the user
flash memory.
A page erase only starts when allowed by PESD in FLASH_SR and FLASH_C2SR.
When a page is protected by PCROP or WRP, it is not erased. Hide protection area and
hide protection area disable provide no protection for erase. A hide protection area when not
protected by PCROP or WRP, can be erased.
PCROP
PCROP WRP
_RDP
No
No
No
Yes
Yes
No
Yes
Yes
No
No
No
Yes
Yes
No
Yes
Yes
1. When PER requested by the non-secure CPU1.
2. When requested by a secure bus master. When requested by a non-secure bus master, no WRPERR is generated and an
illegal access event is generated instead.
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 or
FLASH_C2SR.
2.
Check that flash program and erase operation is allowed by checking PESD in
FLASH_SR or FLASH_C2SR (these checks are recommended even if status may
change due to flash operation requests by the other CPU, to limit the risk of receiving a
bus error when starting page erase).
106/1450
Table 13. Page erase overview
Comment
Page is erased
Page erase aborted (no page erase started)
Requested by CPU2. Secure page is
x
erased.
Requested by CPU1. Secure page erase is
aborted (no secure page erase started)
Page erase aborted (no page erase started)
RM0453 Rev 5
CPU1
CPU2
WRPERR
bus
bus
error
error
No
No
No
Yes
N/A
No
No
No
N/A
(2)
Yes
No
No
RM0453
Illegal
access
event
No
(1)
Yes
Need help?
Do you have a question about the STM32WL5 Series and is the answer not in the manual?