
2002 Microchip Technology Inc.
Preliminary
DS30485A-page 55
PIC18FXX39
5.3
Reading the FLASH Program
Memory
The TBLRD instruction is used to retrieve data from pro-
gram memory and place 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 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 5-4shows the interface between the internal program
memory and the TABLAT.
FIGURE 5-4:
READS FROM FLASH PROGRAM MEMORY
EXAMPLE 5-1:
READING A FLASH PROGRAM MEMORY WORD
(Even Byte Address)
Program Memory
(Odd Byte Address)
TBLRD
TABLAT
TBLPTR = xxxxx1
FETCH
Instruction Register
(IR)
Read Register
TBLPTR = xxxxx0
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
MOVF TABLAT, W
; get data
MOVWF WORD_ODD