EasyManua.ls Logo

Microchip Technology dsPIC30F - Page 102

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...
dsPIC30F Family Reference Manual
DS70052C-page 5-6 © 2004 Microchip Technology Inc.
5.3.2 NVM Address Register
There are two NVM Address Registers - NVMADRU and NVMADR. These two registers when
concatenated form the 24-bit effective address (EA) of the selected row or word for programming
operations. The NVMADRU register is used to hold the upper 8 bits of the EA, while the
NVMADR register is used to hold the lower 16 bits of the EA.
The register pair, NVMADRU:NVMADR, capture the EA<23:0> of the last table-write instruction
that has been executed and select the row of Flash or EEPROM memory to write/erase.
Figure 5-2 shows how the program memory EA is formed for programming and erase operations.
Although the NVMADRU and NVMADR registers are automatically loaded by the table-write
instructions, the user can also directly modify their contents before the programming operation
begins. A write to these registers will be required prior to an erase operation, because no
table-write instructions are required for any erase operation.
Figure 5-2: NVM Addressing with TBLPAG and NVM Address Registers
5.3.3 NVMKEY Register
NVMKEY is a write only register that is used to prevent accidental writes/erasures of Flash or
EEPROM memory. To start a programming or an erase sequence, the following steps must be
taken in the exact order shown:
1. Write 0x55 to NVMKEY.
2. Write 0xAA to NVMKEY.
3. Execute two NOP instructions.
After this sequence, a write will be allowed to the NVMCON register for one instruction cycle. In
most cases, the user will simply need to set the WR bit in the NVMCON register to start the
program or erase cycle. Interrupts should be disabled during the unlock sequence. The code
example below shows how the unlock sequence is performed:
PUSH SR ; Disable interrupts, if enabled
MOV #0x00E0,W0
IOR SR
MOV #0x55,W0
MOV #0xAA,W0
MOV W0,NVMKEY
MOV W0,NVMKEY ; NOP not required
BSET NVMCON,#WR ; Start the program/erase cycle
NOP
NOP
POP SR ; Re-enable interrupts
Refer to Section 5.4.2 “Flash Programming Operations” for further programming examples.
24-bit PM address
TBLPAG Reg
8 bits 16 bits
Using
NVMADR
Addressing
NVMADR Register
NVMADR register loaded with contents of W
register EA used during last table-write instruction.
W Register EA
EA<0> is
Byte Select
TBLPAG<7>
selects User
or Configuration
Space
NVMADRU Register
TBLPAG register during last table-write instruction
NVMADRU register loaded with contents of

Table of Contents

Other manuals for Microchip Technology dsPIC30F