1.4.2 PFM Back to Back Writes

When repetitive writes to nonvolatile memory (Program Flash Memory) are performed, it could result in write/erase failures at some locations. The issue is due to latent timing in the nonvolatile memory controller, which can cause the write instruction to fail under certain conditions.

Work around

To avoid the issue, it is recommended to wait an additional 100 μs after the NVMCON1.WR bit has been set, allowing for the last word to be loaded into the write buffer.


        NVMCON2 = 0x55;
        NVMCON2 = 0xAA;
        NVMCON1bits.WR = 1;
        __delay_us(100);

        NVMCON1bits.WREN = 0;
Note: The __delay_us() function uses a #define macro definition. For the intrinsic __delay_us() function to work correctly, the value of the _XTAL_FREQ must be clearly defined. This macro is defined in the device_config.h file if the code is generated using MCC. The value of XTAL_FREQ is equal to the system clock frequency.

Affected Silicon Revisions

A3A4
XX