
AT32F421
Series Reference Manual
2022.11.11
Page 62
Rev 2.02
[23: 16]
EPP3[7:0]:
Flash erase/write protection byte 3 (stored in the bit [31:
24] of the FLASH_EPPS register)
Bit 6:0 are reserved.
Bit 7 is used to protect Flash memory extension area
0: Erase/write protection is enabled
1: Erase/write protection is disabled
[31: 24]
nEPP3[7: 0]
: Inverse code of EPP3[7: 0]
0x1FFF_F810
[7: 0]
Data2[7: 0]:
User system data 2
[15: 8]
nData2[7: 0]:
Inverse code of Data2[7: 0]
[23: 16]
Data3[7: 0]:
User system data 3
[31: 24]
nData3[7: 0]:
Inverse code of Data3[7: 0]
0x1FFF_F814
[7: 0]
Data4[7: 0]:
User system data 4
[15: 8]
nData4[7: 0]:
Inverse code of Data4[7: 0]
[23: 16]
Data5[7: 0]:
User system data 5
[31: 24]
nData5[7: 0]:
Inverse code of Data5[7: 0]
…
…
…
…
0x1FFF_F9FC
[7: 0]
Data248[7: 0]:
User system data 248
[15: 8]
nData248[7: 0]:
Inverse code of Data248[7: 0]
[23: 16]
Data249[7: 0]:
User system data 249
[31: 24]
nData249[7: 0]:
Inverse code of Data249[7: 0]
5.2 Flash memory operation
5.2.1
Unlock/lock
After reset, Flash memory is protected, by default. The FLASH_CTRL register cannot be written. Write
and erase operation can be performed only when the Flash memory is unlocked.
Unlock procedure:
Flash memory block can be unlocked by writing KEY1 (0x45670123) and KEY2 (0xCDEF89AB) to the
FLASH_UNLOCK register.
Note: Writing an incorrect key sequence leads to a bus error and locks up the Flash memory until
the next reset.
Lock procedure:
Flash memory block can be locked again by setting the OPLK bit in the FLASH_CTRL register.
5.2.2
Erase operation
Erase operation must be performed before programming. Flash memory erase includes sector erase
and mass erase.
Sector erase
Any sector in the Flash memory can be erased with sector erase function independently. To erase a
sector, follow the procedures below:
Check that no Flash memory operation is ongoing by checking the OBF bit of the FLASH_STS
register
Set the sector to be erased in the FLASH_ADDR register
Set the SECERS and ERSTR bits in the FLASH_CTRL register to enable sector erase
Wait until the OBF bit becomes “0” in the FLASH_STS register. Read the EPPERR and ODF bits in
the FLASH_STS register to verify.
Note: When the boot memory is configured as the Flash memory extension area, performing sector-
erase operation erases the entire Flash memory extension area.