EasyManua.ls Logo

Microchip Technology dsPIC30F - Control Registers

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-5
Section 5. Flash and EEPROM Programming
Flash and EEPROM
Programming
5
5.2.2.3 Write Byte Mode
To write a single program memory latch location in Byte mode, the following code sequence can
be used:
; 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
; Load data into working registers
MOV #LOW_BYTE,W2
MOV #MID_BYTE,W3
MOV #HIGH_BYTE,W4
; Write data to the latch
TBLWTH.B W4
,
[W0] ; write high byte
TBLWTL.B W2
,
[W0++] ; write low byte
TBLWTL.B W3
,
[W0++] ; write middle byte
In the code example above, the post-increment operator on the write to the low byte causes the
address in W0 to increment by one. This sets EA<0> = 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.
5.3 Control Registers
Flash and data EEPROM programming operations are controlled using the following
Non-Volatile Memory (NVM) control registers:
NVMCON: Non-Volatile Memory Control Register
NVMKEY: Non-Volatile Memory Key Register
NVMADR: Non-Volatile Memory Address Register
5.3.1 NVMCON Register
The NVMCON register is the primary control register for Flash and EEPROM program/erase
operations. This register selects Flash or EEPROM memory, whether an erase or program oper-
ation will be performed, and is used to start the program or erase cycle.
The NVMCON register is shown in Register 5-1. The lower byte of NVMCOM configures the type
of NVM operation that will be performed. For convenience, a summary of NVMCON setup values
for various program and erase operations is given in Table 5-1.
Table 5-1: NVMCON Register Values
NVMCON Register Values for RTSP Program and Erase Operations
Memory Type Operation Data Size NVMCON Value
Flash PM
Erase 1 row (32 instr. words) 0x4041
Program 1 row (32 instr. words) 0x4001
Data EEPROM
Erase
1 data word 0x4044
16 data words 0x4045
Program
1 data word 0x4004
16 data words 0x4005
Configuration Register
Write
(1)
1 config. register 0x4008
Note 1: The Device Configuration registers may be written to a new value without performing
an erase cycle.

Table of Contents

Other manuals for Microchip Technology dsPIC30F