12.1.1.6 Reading the Program Flash Memory
The TBLRD
instruction retrieves data from program
memory at the TBLPTR location and places it into the TABLAT SFR register. Table reads from program memory
are performed one byte at a time. In addition, TBLPTR can be modified automatically for the
next table read operation.
The CPU operation is suspended during the read, and it resumes immediately after. From the user point of view, TABLAT is valid in the next instruction cycle.
The internal program memory is typically organized by words. The Least Significant bit of the address selects between the high and low bytes of the word. Figure 12-4 shows the interface between the internal program memory and the TABLAT.
Reading a Program Flash Memory Word
MOVLW CODE_ADDR_UPPER ; Load TBLPTR with the base MOVWF TBLPTRU ; address of the word MOVLW CODE_ADDR_HIGH MOVWF TBLPTRH MOVLW CODE_ADDR_LOW MOVWF TBLPTRL READ_WORD: TBLRD*+ ; read into TABLAT and increment MOVF TABLAT, W ; get data MOVWF WORD_EVEN TBLRD*+ ; read into TABLAT and increment MOVFW TABLAT, W ; get data MOVF WORD_ODD