Embedded Flash memory (FLASH) RM0444
90/1390 RM0444 Rev 5
Any wrong sequence locks up the Flash memory option registers until the next system
reset. In the case of a wrong key sequence, a bus error is detected and a Hard Fault
interrupt is generated.
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 as well.
Modifying user options
The option bytes are programmed differently from a Main memory user address.
To modify the value of user options, follow the procedure below:
1. Clear OPTLOCK option lock bit with the clearing sequence described above
2. Write the desired values in the FLASH option registers.
3. Check that no Flash memory operation is ongoing, by checking the BSY1 bit of the
FLASH status register (FLASH_SR)..
4. Set the Options Start bit OPTSTRT of the FLASH control register (FLASH_CR).
5. Wait for the BSY1 bit to be cleared.
Note: Any modification of the value of one option is automatically performed by erasing user
option byte pages first, and then programming all the option bytes with the values contained
in the Flash memory option registers.
The complementary values are automatically computed and written into the complemented
option bytes upon setting the OPTSTRT bit.
Caution: Upon an option byte programming failure (for any reason, such as loss of power or a reset
during the option byte change sequence), the mismatch values of the option bytes are
loaded after reset. Those mismatch values force a secure configuration that might
permanently lock the device. To prevent this, only program option bytes in a safe
environment – safe supply, no pending watchdog, and clean reset line.
Option byte loading
After the BSY1 bit is cleared, all new options are updated into the Flash memory, but not
applied to the system. A read from the option registers still returns the last loaded option
byte values, the new options has effect on the system only after they are loaded.
Option bytes loading is performed in two cases:
– when OBL_LAUNCH bit of the FLASH control register (FLASH_CR) is set
– after a power reset (BOR reset or exit from Standby/Shutdown modes)
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 can be read 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.
During option byte loading, the options are read by double word. ECC on option words is not
taken into account during OBL, but only during direct SW read of option area.