English
Language : 

PIC18F2331 Datasheet, PDF (81/396 Pages) Microchip Technology – 28/40/44-Pin Enhanced Flash Microcontrollers with nanoWatt Technology, High Performance PWM and A/D
PIC18F2331/2431/4331/4431
6.3 Reading the Flash Program
Memory
The TBLRD instruction is used to retrieve data from
program memory and placed 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 a TBLRD instruction 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 6-4
shows the interface between the internal program
memory and the TABLAT.
FIGURE 6-4:
READS FROM FLASH PROGRAM MEMORY
Program Memory
Odd (High) Byte Even (Low) Byte
Instruction Register
(IR)
TBLPTR
LSB = 1
TBLPTR
LSB = 0
TABLAT
Read Register
EXAMPLE 6-1: READING A FLASH PROGRAM MEMORY WORD
READ_WORD
MOVLW CODE_ADDR_UPPER
MOVWF TBLPTRU
MOVLW CODE_ADDR_HIGH
MOVWF TBLPTRH
MOVLW CODE_ADDR_LOW
MOVWF TBLPTRL
TBLRD*+
MOVFW TABLAT
MOVWF WORD_EVEN
TBLRD*+
MOVFW TABLAT
MOVWF WORD_ODD
; Load TBLPTR with the base
; address of the word
; read into TABLAT and increment TBLPTR
; get data
; read into TABLAT and increment TBLPTR
; get data
 2003 Microchip Technology Inc.
Preliminary
DS39616B-page 79