Embedded Flash memory (FLASH)
unlock this register:
1.
Unlock the FLASH_CR with the LOCK clearing sequence (refer to
memory).
2.
Write OPTKEY1 = 0x08192A3B in the
3.
Write OPTKEY2 = 0x4C5D6E7F in the FLASH_OPTKEYR register.
The user options can be protected against unwanted erase/program operations by setting
the OPTLOCK bit by software.
Note:
If LOCK is set by software, OPTLOCK is automatically set too.
Modifying user options
The option bytes are programmed differently from a main memory user address. It is not
possible to modify independently user options of bank 1 or bank 2. The users Options of the
bank 1 are modified first.
To modify the user options value, follow the procedure below:
1.
Check that no Flash memory operation is on going by checking the BSY bit in the
status register
2.
Clear OPTLOCK option lock bit with the clearing sequence described above.
3.
Write the desired options value in the options registers:
(FLASH_OPTR),
Flash Bank 1 PCROP End address register
area A address register
register
(FLASH_PCROP2SR),
(FLASH_PCROP2ER),
(FLASH_WRP2AR),
4.
Set the Options Start bit OPTSTRT in the
5.
Wait for the BSY bit to be cleared.
Note:
Any modification of the value of one option is automatically performed by erasing both user
option bytes pages first (bank 1 and bank 2) and then programming all the option bytes with
the values contained in the flash option registers.
Option byte loading
After the BSY bit is cleared, all new options are updated into the flash but they are not
applied to the system. They will have effect on the system when they are loaded. Option
bytes loading is performed in two cases:
–
–
Option byte loader performs a read of the options block and stores the data into internal
option registers. These internal registers configure the system and cannot be read with by
software. Setting OBL_LAUNCH generates a reset so the option byte loading is performed
under system reset.
Each option bit has also its complement in the same double word. During option loading, a
verification of the option bit and its complement allows to check the loading has correctly
taken place.
98/1693
(FLASH_SR).
Flash Bank 1 PCROP Start address register
(FLASH_WRP1AR),
(FLASH_WRP1BR),
Flash Bank 2 PCROP End address register
Flash Bank 2 WRP area A address register
Flash Bank 2 WRP area B address register
when OBL_LAUNCH bit is set in the
after a power reset (BOR reset or exit from Standby/Shutdown modes).
DocID024597 Rev 3
Flash option key register
(FLASH_PCROP1ER),
Flash Bank 1 WRP area B address
Flash Bank 2 PCROP Start address register
Flash control register
Flash control register
Unlocking the Flash
(FLASH_OPTKEYR).
Flash option register
(FLASH_PCROP1SR),
Flash Bank 1 WRP
(FLASH_WRP2BR).
(FLASH_CR).
(FLASH_CR).
RM0351
Flash
Need help?
Do you have a question about the STM32L4x6 and is the answer not in the manual?
Questions and answers