56
/
838
Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
Check the FLASH_ STS.BUSY bit to confirm that there are no other flash operations in progress;
Unlock the FLASH_CTRL.OPTWE bit;
Set the FLASH_CTRL.OPTER bit to '1';
Set the FLASH_CTRL.START bit to '1';
Wait for the FLASH_ STS.BUSY bit to change to '0';
Read the erased option byte and verify it.
Option byte area programming process:
Check the FLASH_ STS.BUSY bit to confirm that there are no other flash operations in progress;
Unlock the FLASH_CTRL.OPTWE bit;
Set the FLASH_CTRL.OPTPG bit to '1';
Writing the word to be programmed to the specified address;
Wait for the FLASH_ STS.BUSY bit to change to '0';
Read the written address and verify the data.
ECC function
The Flash module supports the ECC function to realize 1-bit error detection and 1-bit error correction. ECC encoding
and decoding (error correction, error detection) are automatically performed by hardware. If an error is detected, the
error bit is set and an interrupt is generated.
Instruction prefetching
The instruction prefetch function of Flash module supports the prefetch Buffer of 16B. Through instruction
prefetching, the instruction execution efficiency of CPU can be improved. The instruction prefetch function can be
configured to be enabled or disabled through the register, and it is enabled by default.
Option byte
Option byte block is mainly used to configure read-write protection, boot mode configuration, software/hardware
watchdog configuration and reset options when the system is in standby/stop0/stop2 mode, and bus address space is
allocated for read-write access. They consist of byte with 9 options: 4 byte for write protection, 2 bytes for read
protection, 1 byte for configuration option, 2 bytes defined by user, These 9 bytes need to be written through the bus.
The option byte block also contains the complement codes corresponding to these 9 option bytes. These complement
codes need to be automatically calculated by hardware when the option bytes are written in the bus, and written into
Flash together, and used for verification when the option bytes are read.
By default, the option byte block is always readable and write-protected. To write (program/erase) the option byte
block, first unlock the Flash, then unlock the option byte: write the correct key-value sequence (KEY1 = 0x45670123,
KEY2 = 0xCDEF89AB) in the FLASH_OPTKEY, and then write the option byte block will be allowed. If the
sequence is wrong or the key value is wrong, a bus error will be returned and the option byte will be locked until the
next reset. If it is necessary to set the lock normally, it can be realized by writing 0 to the FLASH_CTRL.OPTWE
bit by software, and then the option byte can be unlocked by writing the correct key-value series in the
FLASH_OPTKEY.