English
Language : 

RM0313 Datasheet, PDF (59/900 Pages) STMicroelectronics – This reference manual targets application developers
RM0313
Embedded Flash memory
3.3.3
Write unprotection
To disable the write protection, two application cases are provided:
• Case 1: Read protection disabled after the write unprotection:
– Erase the entire option byte area by using the OPTER bit in the Flash memory
control register (FLASH_CR).
– Program the code 0xAA in the RDP byte to unprotect the memory. This operation
forces a Mass Erase of the main Flash memory.
– Set the OBL_LAUNCH bit in the Flash control register (FLASH_CR) to reload the
option bytes (and the new WRP[3:0] bytes), and to disable the write protection.
• Case 2: Read protection maintained active after the write unprotection, useful for in-
application programming with a user bootloader:
– Erase the entire option byte area by using the OPTER bit in the Flash memory
control register (FLASH_CR).
– Set the OBL_LAUNCH bit in the Flash control register (FLASH_CR) to reload the
option bytes (and the new WRP[3:0] bytes), and to disable the write protection.
Option byte block write protection
The option bytes are always read-accessible and write-protected by default. To gain write
access (Program/Erase) to the option bytes, a sequence of keys (same as for lock) has to
be written into the OPTKEYR. A correct sequence of keys gives write access to the option
bytes and this is indicated by OPTWRE in the FLASH_CR register being set. Write access
can be disabled by resetting the bit through software.
3.4
Flash interrupts
Interrupt event
End of operation
Write protection error
Programming error
Table 6. Flash interrupt request
Event flag
EOP
WRPRTERR
PGERR
Enable control bit
EOPIE
ERRIE
ERRIE
DocID022448 Rev 4
59/900
69