User information configuration registers (UICR) are written in the same way as flash. After UICR has been written, the new UICR configuration will only take effect after a reset.
UICR is only accessible by secure code. Any write from non-secure code will be faulted.
To lock the chip after uploading non-secure code, do the follolwing steps:
- Block access to secure code by setting UICR register to protected.
- Use the register WRITEUICRNS, via non-secure debugger, to set APPROTECT (APPROTECT is automatically written to 0x00000000 by the NVMC).
UICR can only be written nWRITE number of times before an erase must be performed using ERASEALL.
The time it takes to write a word to the UICR is specified by tWRITE. The CPU is stalled if the CPU executes code from the flash while the NVMC is writing to the UICR.