Embedded flash memory
The sequence is as follows:
•
Check that no flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register.
•
Unlock the OPTWRE bit in the FLASH_CR register.
•
Set the OPTPG bit in the FLASH_CR register
•
Write the data (half-word) to the desired address
•
Wait for the BSY bit to be reset.
•
Read the programmed value and verify.
When the flash memory read protection option is changed from protected to unprotected, a
Mass Erase of the main flash memory is performed before reprogramming the read
protection option. If the user wants to change an option other than the read protection
option, then the mass erase is not performed. The erased state of the read protection option
byte protects the flash memory.
Erase procedure
The option byte erase sequence (OPTERASE) is as follows:
•
Check that no flash memory operation is ongoing by reading the BSY bit in the
FLASH_SR register.
•
Unlock the OPTWRE bit in the FLASH_CR register.
•
Set the OPTER bit in the FLASH_CR register.
•
Set the STRT bit in the FLASH_CR register.
•
Wait for BSY to reset.
•
Read the erased option bytes and verify.
54/874
RM0366 Rev 5
RM0366
Need help?
Do you have a question about the STM32F301 6 Series and is the answer not in the manual?