
AT32F413
Series Reference Manual
2022.06.27
Page 71
Rev 2.00
5.2.4
Read operation
Flash memory can be accessed through AHB bus of the CPU.
5.3 External memory operation
External memory has the same operation method as that of Flash memory, including read, unlock,
erase and programming, except that the external memory only supports 32-bit and 16-bit
operations, rather than 8 bits.
5.4 User system data area operation
5.4.1
Unlock/lock
After reset, user system data area is protected, by default.
Write and erase operations can be performed
only after the Flash memory is unlocked and then the user system data area is unlocked.
Unlock procedure:
Flash memory block can be unlocked by writing KEY1 (0x45670123) and KEY2 (0xCDEF89AB) to the
FLASH_UNLOCK register;
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 the
user system data area can be programmed (write/erase).
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 be erased 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 will halt CPU until the completion
of erase.