Embedded Flash memory interface
RM0090
92/1731
DocID018909 Rev 11
3.7.2
Programming user option bytes
To run any operation on this sector, the option lock bit (OPTLOCK) in the Flash option
control register (FLASH_OPTCR) must be cleared. To be allowed to clear this bit, you have
to perform the following sequence:
1.
Write OPTKEY1 = 0x0819 2A3B in the Flash option key register (FLASH_OPTKEYR)
2. Write OPTKEY2 = 0x4C5D 6E7F in the Flash option key register (FLASH_OPTKEYR)
The user option bytes can be protected against unwanted erase/program operations by
setting the OPTLOCK bit by software.
Modifying user option bytes on STM32F405xx/07xx and STM32F415xx/17xx
To modify the user option value, follow the sequence below:
1.
Check that no Flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register
2. Write the desired option value in the FLASH_OPTCR register.
3. Set the option start bit (OPTSTRT) in the FLASH_OPTCR register
4. Wait for the BSY bit to be cleared.
Note:
The value of an option is automatically modified by first erasing the user configuration sector
and then programming all the option bytes with the values contained in the FLASH_OPTCR
register.
Modifying user option bytes on STM32F42xxx and STM32F43xxx
The user option bytes for bank 1 and bank 2 cannot be modified independently. They must
be updated concurrently.
To modify the user option byte value, follow the sequence below:
1.
Check that no Flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register
2. Write the bank 2 option byte value in the FLASH_OPTCR1 register
3. Write the bank 1 option byte value in the FLASH_OPTCR register.
4. Set the option start bit (OPTSTRT) in the FLASH_OPTCR register
5. Wait for the BSY bit to be cleared
Option bytes (word, address 0x1FFE C008)
Bit 15:12
0xF: not used
nWRP
: Flash memory write protection option bytes for bank 2. Sectors 12 to 23 can be write
protected.
Bits 11: 0
nWRPi:
If SPRMOD is reset (default value):
0: Write protection active on sector i.
1: Write protection not active on sector i.
If SPRMOD is set (active):
0: PCROP protection not active on sector i.
1: PCROP protection active on sector i.
Table 16. Description of the option bytes
(STM32F42xxx and STM32F43xxx) (continued)