AT32F425
Series Reference Manual
2022.03.30
Page 71
Ver 2.01
When KEY1 (0x45670123) and KEY2 (0xCDEF89AB) is written to the FLASH_USD_UNLOCK register,
the USDULKS bit in the FLASH_CTRL register will be automatically set by hardware, indicating that it
supports write/erase operation to the user system data area.
Note: Writing an incorrect key sequence leads to bus error and the Flash memory is also locked until
the next reset.
Lock procedure:
User system data area is locked by clearing the USDULKS bit in the FLASH_CTRL register by software.
5.4.2
Erase operation
Erase operation must be done before programming. User system data area can perform erase operation
independently.
Below should be followed during page erase:
Check the OBF bit in the FLASH_STS register to confirm that there is no other programming
operation in progress;
Set the USDERS and ERSTR bit in the FLASH_CTRL register to enable erase operation;
Wait until the OBF bit becomes “0” in the FLASH_STS register. Read the ODF bit in the
FLASH_STSx register to verify the erase result.
Note: Read operation to the Flash memory during programming halts CPU and waits until the
completion of erase. The internal HICK must be enabled prior to erase operation.