English
Language : 

PIC18LF24K Datasheet, PDF (128/594 Pages) –
PIC18(L)F26/45/46K40
11.1.3
READING THE PROGRAM FLASH
MEMORY
The TBLRD instruction retrieves data from program
memory and places it into data RAM. Table reads from
program memory are performed one byte at a time.
TBLPTR points to a byte address in program space.
Executing TBLRD places the byte pointed to into
TABLAT. 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 11-4
shows the interface between the internal program
memory and the TABLAT.
FIGURE 11-4:
READS FROM PROGRAM FLASH MEMORY
Program Memory
(Even Byte Address) (Odd Byte Address)
Instruction Register
(IR)
FETCH
TBLPTR = xxxxx1
TBLPTR = xxxxx0
TBLRD
TABLAT
Read Register
EXAMPLE 11-1: READING A PROGRAM FLASH MEMORY WORD
READ_WORD
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
TBLRD*+
MOVF
MOVWF
TBLRD*+
MOVFW
MOVF
CODE_ADDR_UPPER
TBLPTRU
CODE_ADDR_HIGH
TBLPTRH
CODE_ADDR_LOW
TBLPTRL
TABLAT, W
WORD_EVEN
TABLAT, W
WORD_ODD
; Load TBLPTR with the base
; address of the word
; read into TABLAT and increment
; get data
; read into TABLAT and increment
; get data
 2016 Microchip Technology Inc.
Preliminary
DS40001816C-page 128