![ARTERY AT32WB415 Series Скачать руководство пользователя страница 67](http://html1.mh-extra.com/html/artery/at32wb415-series/at32wb415-series_reference-manual_2977599067.webp)
AT32WB415
Series Reference Manual
2022.04.13
Page 67
Ver 2.00
5.2.4
Read operation
Flash memory can be accessed through AHB bus of the CPU.
5.3 Main Flash memory extension area
Bootloader code area can also be programmed as the extension area of the main Flash memory to store
user-application code. When used as main Flash memory extension area, it behaves like the main Flash
memory, including read, unlock, erase and programming operations.
5.4 User system data area
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 before the unlock operation for the user system data area.
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 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.