Page Read

PFM can be read one word or 128-word page at a time. A page is read by setting the NVMADR registers to an address within the target page and setting the NVMCMD bits to ‘b010. The page content is then transferred from PFM to the buffer RAM by starting the read operation by setting the GO bit.

The sequence of events for reading a 128-word page of PFM is:

  1. 1.Set the NVMADR registers to an address within the intended page.
  2. 2.Set the NVMCMD control bits to ‘b010 (Page Read).
  3. 3.Set the GO bit to start the PFM page read.
  4. 4.Monitor the GO bit or NVMIF interrupt flag to determine when the read has completed.

Reading a Page of Program Flash Memory in C

// Code sequence to read one page of PFM to Buffer Ram
// PFM target address is specified by PAGE_ADDR

// Load NVMADR with the base address of the memory page
NVMADR = PAGE_ADDR;              

NVMCON1bits.CMD = 0x02;          // Set the page read command
NVMCON0bits.GO = 1;              // Start page read
while (NVMCON0bits.GO);          // Wait for the read operation to complete