GD32F20x User Manual
53
2.3.10.
Page erase/program protection
The FMC provides page erase/program protection functions to prevent inadvertent operations
on the Flash memory. The page erase or program will not be accepted by the FMC on
protected pages. If the page erase or program command is sent to the FMC on a protected
page, the WPERR bit in the FMC_STATx registers will then be set by the FMC. If the WPERR
bit is set and the ERRIE bit is also set to 1 to enable the corresponding interrupt, then the
Flash operation error interrupt will be triggered by the FMC to draw the attention of the CPU.
The page protection function can be individually enabled by configuring the WP [31:0] bit field
to 0 in the option bytes. If a page erase operation is executed on the option bytes block, all
the Flash Memory page protection functions will be disabled. When WP in the option bytes is
modified, a system reset followed is necessary.
2.3.11.
Security protection
The FMC provides a security protection function to prevent illegal code/data access on the
Flash memory. This function is useful for protecting the software/firmware from illegal users.
No protection: when setting SPC byte and its complement value to 0x5AA5, no protection
performed. The main flash and option bytes block are accessible by all operations.
Under protection: when setting SPC byte and its complement value to any value except
0x5AA5, the security protection is performed. Note that a power reset should be followed
instead of a system reset if the SPC modification is performed while the debug module is still
connected to JTAG/SWD device. Under the security protection, the main flash can only be
accessed by user code and the first 4KB flash is under erase/program protection. In debug
mode, boot from SRAM or boot from boot loader mode, all operations to main flash is
forbidden. If a read operation to main flash is in debug mode, boot from SRAM or boot from
boot loader mode, a bus error will be generated. If a program/erase operation to main flash
is in debug mode, boot from SRAM or boot from boot loader mode, the WPERR bit in
FMC_STATx registers will be set. Option bytes block are accessible by all operations, which
can be used to disable the security protection. If program back to no protection level by setting
SPC byte and its complement value to 0x5AA5, a mass erase for main flash will be performed.
Note:
In the case of read protection, the first 4k of flash cannot be programmed or erased.
2.4.
Register definition
FMC start address: 0x4002 2000
2.4.1.
Wait state register (FMC_WS)
Address offset: 0x00
Reset value: 0x0000 0000
This register has to be accessed by word (32-bit)
Summary of Contents for GD32F20 Series
Page 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Page 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Page 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Page 385: ...GD32F20x User Manual 385 ...
Page 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...