Writing Access

The WREN bit must be set to enable writes. This prevents accidental writes to the CONFIG words due to errant (unexpected) code execution. The WREN bit should be kept clear at all times, except when updating the CONFIG words. The WREN bit is not cleared by hardware. The WR bit will be inhibited from being set unless the WREN bit is set.

The user needs to load the TBLPTR and TABLAT register with the respective address and data before executing the write command. An unlock sequence needs to be followed to enable the write (see NVM Unlock Sequence). When attepmting to write the Configuration words, if the WRTC configuration bit is zero or if TBLPTR points an invalid address location (see Table 1), then the WR bit is cleared without any effect and the WRERR bit is set.

A single CONFIG word byte is written immediately and the operation includes an implicit erase cycle for that byte (it is not necessary to set FREE). CPU execution is stalled and at the completion of the write cycle, the WR bit is cleared in hardware and the NVM Interrupt Flag bit (NVMIF) is set. The new CONFIG value takes effect when the CPU resumes operation.

Table 1. User ID, Dev/REV ID and Configuration Word Access (NVMREG = 0bx1)
Address Function Read Access Write Access
20 0000h-20 000Fh User IDs Yes Yes
3F FFFCh-3F FFFFh Revision ID/Device ID Yes No
30 0000h-30 000Bh Configuration Words 1-6 Yes Yes