Flash program memory and data EEPROM (FLASH) RM0367
100/1043 RM0367 Rev 7
The only way to remove a protection from a sector is to request a mass erase (which
changes the protection level to 0 and disables PcROP): when PcROP is disabled, the
protection on sectors can be changed freely.
3.4.3 Protections against unwanted write/erase operations
The memory interface implements two ways to protect against unwanted write/erase
operations which are valid for all matrix or only for specific sectors of the Flash program
memory.
As explained in the Unlocking/locking operations section, the user can:
• Write/erase to the data EEPROM only when PELOCK = 0 in the FLASH_PECR
register.
• Write/erase to the Option bytes area only when PELOCK = 0 and OPTLOCK = 0 in the
FLASH_PECR register.
• Write/erase to the Flash program memory only when PELOCK = 0 and PRGLOCK = 0
in the FLASH_PECR register.
To see the sequences to set PELOCK, PRGLOCK and OPTLOCK, refer to the Unlocking
the data EEPROM and the FLASH_PECR register, Unlocking the Flash program memory
and Unlocking the Option bytes area sections.
In the Flash program memory, it is possible to add another write protection with the sector
granularity. When PcROP is disabled (WPRMODE = 0), the bits of WRPROT are used to
enable the write protection on the sectors. The polarity is opposed relatively to PcROP: to
protect a sector, it is necessary to set the bit to 1; to remove the protection, it is necessary to
set the bit to 0. Table 20 is valid for a write protection as well. As explained, when PcROP is
enabled, the sectors protected against read are also protected against write/erase. It is
always possible to change the write protection on sectors both in Level 0 and Level 1
(provided that it is possible to write/erase to Option bytes and that PcROP is disabled).
Table 21 resumes the protections.
Table 21. Memory access vs mode, protection and Flash program memory sectors
Flash program memory
sectors
Mode
User
(including In Application
Programming)
no Debug, or
no Boot in RAM, or
no Boot in System memory
User
in Debug, or
with Boot in RAM, or
with Boot in System memory
RDP
Level 1
Level 0
Level 2 Level 0 Level 1 Level 2
Flash program memory
(FLASH_PRGLOCK = 1)
RRR
Protected
(no access)
NA
(1)
Flash memory
(FLASH_PRLOCK = 0)
R / W R / W R / W
Protected
(no access)
NA
(1)
Flash program memory
in WRP pages
RRR
Protected
(no access)
NA
(1)