6.1.6.2.1 Word Programming Sequence

Follow this sequence of steps for word or quad word programming:

  1. For the PIC32CX-BZ6, program the write data into NVMDATA0 and NVMDATA1 for double word programming and use NVMDATA0 to NVMDATA7 for quad double word.

    For the PIC32CX-BZ3, program the write data into NVMDATA0 for single word programming and use NVMDATA0 to NVMDATA3 for quad word.

  2. Load NVMADDR with the address to be programmed.
  3. Run the sequencer start unlock sequence using word (quad) program command to start the sequence:
    1. Set NVMCON.WREN=1 (allow writes to NVMCON.NVMWR) and set NVMCON.NVMOP to the desired operation WORD_NVMOP or QUAD_NVMOP (using a single write).
    2. Unlock the sequence to be followed for the programming to take place.
      1. Set NVMKEY = 0x00000000 (Reset key)
      2. Set NVMKEY = 0xAA996655
      3. Set NVMKEY = 0x556699AA
    3. Write to the target register NVMCONSET to set the NVMWR bit (not the NVMCON register itself). This starts the FC operation.
    Note: The program sequence completes when the hardware clears the NVMCON.NVMWR bit. This pulses a Flash event.
  4. Clear the NMVCON.WREN bit.
  5. Check the NVMCON.NVMERR and NVMCON.BORERR bits to ensure that the programming is successful.