33.3.7.2 NVM Programming
If the device is unlocked, it is possible to write directly to the NVM Controller using the UPDI - this will lead to unpredictable code execution if the CPU is active during the NVM programming. To avoid this, the following NVM Programming sequence should be executed.
- Follow the Chiperase procedure as described in Chip Erase. If the part is already unlocked, this point can be skipped.
- Enter the NVMPROG KEY by using the
KEY
instruction. See Table 33-6 for the NVMPROG signature. - Optional: Read the NVMPROG field in the KEY_STATUS register to see that the KEY has been activated.
- Write the Reset signature into the ASI_RESET_REQ register. This will issue a System Reset.
- Write 0x00 to the Reset signature in ASI_RESET_REQ register to clear the System Reset.
- Read NVMPROG in ASI_SYS_STATUS.
- NVM Programming can start when NVMPROG == 1 in the ASI_SYS_STATUS register. If NVMPROG == 0, go to point 6 again.
- Write data to NVM through the UPDI.
- Write the Reset signature into the ASI_RESET_REQ register. This will issue a System Reset.
- Write 0x00 to the Reset signature in ASI_RESET_REQ register to clear the System Reset.
- Programming is complete.