Download Print this page

ST STM32F301 6 Series Reference Manual page 57

Advanced arm-based 32-bit mcus

Advertisement

RM0366
3.3.2
Write protection
The write protection is implemented with a granularity of 2 pages. It is activated by
configuring the WRP[1:0] option bytes, and then by reloading them by setting the
OBL_LAUNCH bit in the FLASH_CR register.
If a program or an erase operation is performed on a protected, the flash memory returns a
WRPRTERR protection error flag in the Flash memory Status Register (FLASH_SR).
Write unprotection
To disable the write protection, two application cases are provided:
Case 1: Read protection disabled after the write unprotection:
Case 2: Read protection maintained active after the write unprotection, useful for in-
application programming with a user bootloader:
3.3.3
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
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.
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.
Table 6. Flash interrupt request
Event flag
EOP
WRPRTERR
PGERR
RM0366 Rev 5
Embedded flash memory
Enable control bit
EOPIE
ERRIE
ERRIE
57/874
67

Advertisement

loading
Need help?

Need help?

Do you have a question about the STM32F301 6 Series and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Stm32f301 8 seriesStm32f318 8 series