Why can't I write to Program / Boot Flash memory?
If you try to write to Program / Boot Flash Memory on the PIC32MZ and are only able to read back the default bit values (0xFF), your writes to memory were not successful.
Before writing to Program / Boot Flash Memory, you need to unlock it first. This prevents you from accidentally writing to this important memory area. The device has two registers which control the write lock on the memory:
- NVMPWP: Program flash write-protect register
- NVMBWP: Flash boot (page) write-protect register
These registers need to be configured by performing the unlock sequence and performing atomic instructions on the registers. Please see the PIC32 Family reference manual (search the device page on Microchip.com) for more information.