EasyManua.ls Logo

Microchip Technology dsPIC30F - Section 5. Flash and Eeprom Programming

Microchip Technology dsPIC30F
738 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
© 2004 Microchip Technology Inc. DS70052C-page 5-3
Section 5. Flash and EEPROM Programming
Flash and EEPROM
Programming
5
Figure 5-1: Addressing for Table Instructions
5.2.1 Using Table Read Instructions
Table reads require two steps. First, an address pointer is setup using the TBLPAG register and
one of the W registers. Then, the program memory contents at the address location may be read.
5.2.1.1 Read Word Mode
The following code example shows how to read a word of program memory using the table
instructions in Word mode:
; Setup the address pointer to program space
MOV #tblpage(PROG_ADDR),W0 ; get table page value
MOV W0,TBLPAG ; load TBLPAG register
MOV #tbloffset(PROG_ADDR),W0 ; load address LS word
; Read the program memory location
TBLRDH [W0],W3 ; Read high byte to W3
TBLRDL [W0],W4 ; Read low word to W4
5.2.1.2 Read Byte Mode
; Setup the address pointer to program space
MOV #tblpage(PROG_ADDR),W0 ; get table page value
MOV W0,TBLPAG ; load TBLPAG register
MOV #tbloffset(PROG_ADDR),W0 ; load address LS word
; Read the program memory location
TBLRDH.B [W0],W3 ; Read high byte to W3
TBLRDL.B [W0++],W4 ; Read low byte to W4
TBLRDL.B [W0++],W5 ; Read middle byte to W5
In the code example above, the post-increment operator on the read of the low byte causes the
address in the working register to increment by one. This sets EA<0> to a ‘1’ for access to the
middle byte in the third write instruction. The last post-increment sets W0 back to an even
address, pointing to the next program memory location.
TBLPAG
8 bits from TBLPAG
EA
EA<0> Selects Byte
24-bit EA
TBLPAG<7> Selects
User/Configuration
Space
0
15
0
7
16 bits from Wn
Note: The tblpage() and tbloffset() directives are provided by the Microchip
assembler for the dsPIC30F. These directives select the appropriate TBLPAG and
W register values for the table instruction from a program memory address value.
Refer to the Microchip software tools documentation for further details.

Table of Contents

Other manuals for Microchip Technology dsPIC30F