# 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.

1. 1.Follow the Chiperase procedure as described in Chip Erase. If the part is already unlocked, this point can be skipped.
2. 2.Enter the NVMPROG KEY by using the KEY instruction. See Table 2 for the NVMPROG signature.
3. 3.Optional: Read the NVMPROG field in the KEY_STATUS register to see that the KEY has been activated.
4. 4.Write the Reset signature into the ASI_RESET_REQ register. This will issue a System Reset.
5. 5.Write 0x00 to the Reset signature in ASI_RESET_REQ register to clear the System Reset.