PIC18F2331/2431/4331/4431
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 8-4
8.3
Reading the Flash Program
Memory
The TBLRD instruction is used to retrieve data from
program memory and place it into data RAM. Table
reads from program memory are performed one byte at
a time.
shows the interface between the internal program
memory and the TABLAT.
TBLPTR points to a byte address in program space.
Executing a TBLRDinstruction places the byte pointed
to into TABLAT. In addition, TBLPTR can be modified
automatically for the next table read operation.
FIGURE 8-4:
READS FROM FLASH PROGRAM MEMORY
Program Memory
(Even Byte Address)
(Odd Byte Address)
TBLPTR = xxxxx1
TBLPTR = xxxxx0
Instruction Register
(IR)
TABLAT
Read Register
FETCH
TBLRD
EXAMPLE 8-1:
READING A FLASH PROGRAM MEMORY WORD
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
CODE_ADDR_UPPER
TBLPTRU
CODE_ADDR_HIGH
TBLPTRH
CODE_ADDR_LOW
TBLPTRL
; Load TBLPTR with the base
; address of the word
READ_WORD
TBLRD*+
MOVF
; read into TABLAT and increment TBLPTR
; get data
TABLAT,W
MOVWF
TBLRD*+
MOVF
WORD_EVEN
; read into TABLAT and increment TBLPTR
; get data
TABLAT,W
WORD_ODD
MOVWF
2010 Microchip Technology Inc.
DS39616D-page 89