
AT32F421
Series Reference Manual
2022.11.11
Page 71
Rev 2.02
this register, security library should be unlocked first by writing 0xA35F6D24 to the SLIB_UNLOCK
register. Then check the SLIB_ULKF bit in the SLIB_MISC_STS register to verify if it is unlocked
successfully. If successful, write the programmed value into the security library setting register.
To enable security library , follow the steps below:
Check that no Flash memory operation is ongoing by checking the OBF bit in the FLASH_STS
register
Write 0xA35F6D24 to the SLIB_UNLOCK register to unlock security library.
Check the SLIB_ULKF bit of SLIB_MISC_STS register to verify if it is unlocked successfully.
If the security library is located in Flash memory, then set the sectors to be protected (including the
addresses of instruction and data areas) in the SLIB_SET_RANGE register; if the security library is
located in the Flash extension area, then set the EM_SLIB_SET register
Wait until the OBF bit becomes “0”
Set a security library password in the SLIB_SET_PWD register
Wait until the OBF bit becomes “0”
Program the code to be saved in security library
Perform a system reset, and then reload security library setting words
Read the SLIB_STS0/STS1 register to verify the security library settings
Note:
The main Flash memory and Flash extension area are not intended to be configured as security library
at the same time.
Security library must be enabled before the Flash access protection is activated.
To unlock security library, follow the steps below:
Write the previously set security library password to the SLIB_PWD_CLR register
Wait until the OBF bit becomes “0”
Perform a system reset, and then reload security library setting word
Read the SLIB_STS0 register to check the security library settings
Note: Deactivating the security library will automatically perform mass erase on the main memory, main
memory extension area and security library setting block.
5.7.2
Boot memory used as memory extension area
There is only one chance for users to program the boot memory as the Flash memory extension area.
Upon successful configuration, the extension area has the same features as those of Flash memory.
To configure boot memory as a Flash memory extension area, follow the procedure below:
Check the current mode of the boot memory by reading the bit 0 in the SLIB_STS0 register
Write the value 0xA35F6D24 to the SLIB_UNLOCK register to unlock the boot memory mode
settings
Write non-0xFF to the bit [7: 0] in the BTM_MODE_SET register
Wait until the OBF bit becomes 0
Perform a system reset, and reload setting words
Read the SLIB_STS0 register to verify
Note: The main Flash extension area are must be set before the Flash access protection is
activated.