11.3.1 Reading the DFM

To read a DFM location, the user must write the address to the NVMADR register, enable NVM control by setting the NVMEN bit, and then set the RD control bit. The data is available on the very next instruction cycle; therefore, the NVMDAT register can be read by the next instruction. NVMDAT will hold this value until another read operation, or until it is written to by the user (during a write operation).

The basic process is shown in the following flowchart.

Figure 11-11. DFM Read Flowchart

DFM Read

; Data Flash Memory Address to read
        BSF     NVMCON0, NVMEN          ; Enable NVM
        MOVF    DFM_ADDRL, W            ;
        MOVWF   NVMADRL                 ; Setup Address low byte
        MOVF    DFM_ADDRH, W            ;
        MOVWF   NVMADRH                 ; Setup Address high byte
        MOVF    DFM_ADDRU, W            ;
        MOVWF   NVMADRU                 ; Setup Address upper byte
        BSF     NVMCON1, RD             ; Issue EE Read
        MOVF    NVMDAT, W               ; W = EE_DATA 
        BCF     NVMCON0, NVMEN          ; Disable NVM

Only byte reads are supported for DFM. Reading a block of DFM with a SECRD operation is not supported.