DSPIC30F2012 Microchip Technology Inc., DSPIC30F2012 Datasheet - Page 57

no-image

DSPIC30F2012

Manufacturer Part Number
DSPIC30F2012
Description
Dspic30f2011/2012/3012/3013 High-performance Digital Signal Controllers
Manufacturer
Microchip Technology Inc.
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
DSPIC30F2012-20E/ML
Manufacturer:
MICROCHIP/微芯
Quantity:
20 000
Part Number:
DSPIC30F2012-20E/SO
Manufacturer:
MICROCHIP/微芯
Quantity:
20 000
Part Number:
DSPIC30F2012-20I/ML
Manufacturer:
MICROCHIP/微芯
Quantity:
20 000
Part Number:
DSPIC30F2012-20I/SO
Manufacturer:
MICROCHI
Quantity:
20 000
Part Number:
DSPIC30F2012-20I/SO
0
Part Number:
DSPIC30F2012-20I/SP
Manufacturer:
Microchip Technology
Quantity:
135
Part Number:
DSPIC30F2012-20I/SP
Manufacturer:
MICROCHIP/微芯
Quantity:
20 000
6.3
To write an EEPROM data location, the following
sequence must be followed:
1.
2.
3.
EXAMPLE 6-4:
© 2006 Microchip Technology Inc.
; Point to data memory
; The NVMADR captures last table access address
; Select data EEPROM for 1 word op
; Operate key to allow write operation
; Write cycle will complete in 2mS. CPU is not stalled for the Data Write Cycle
; User can poll WR bit, use NVMIF or Timer IRQ to determine write complete
Erase data EEPROM word.
a)
b)
c)
d)
e)
f)
g)
h)
Write data word into data EEPROM write
latches.
Program 1 data word into data EEPROM.
a)
b)
c)
d)
e)
f)
g)
MOV
MOV
MOV
MOV
TBLWTL
MOV
MOV
DISI
MOV
MOV
MOV
MOV
BSET
NOP
NOP
Writing to the Data EEPROM
Select word, data EEPROM erase, and set
WREN bit in NVMCON register.
Write address of word to be erased into
NVMADR.
Enable NVM interrupt (optional).
Write ‘55’ to NVMKEY.
Write ‘AA’ to NVMKEY.
Set the WR bit. This begins erase cycle.
Either poll NVMIF bit or wait for NVMIF
interrupt.
The WR bit is cleared when the erase cycle
ends.
Select word, data EEPROM program, and
set WREN bit in NVMCON register.
Enable NVM write done interrupt (optional).
Write ‘55’ to NVMKEY.
Write ‘AA’ to NVMKEY.
Set the WR bit. This begins program cycle.
Either poll NVMIF bit or wait for NVM
interrupt.
The WR bit is cleared when the write cycle
ends.
#LOW_ADDR_WORD,W0
#HIGH_ADDR_WORD,W1
W1
#LOW(WORD),W2
W2
#0x4004,W0
W0
#5
#0x55,W0
W0
#0xAA,W1
W1
NVMCON,#WR
,
,
,
,
,
DATA EEPROM WORD WRITE
TBLPAG
[ W0]
NVMCON
NVMKEY
NVMKEY
dsPIC30F2011/2012/3012/3013
; Init pointer
; Get data
; Write data
; Block all interrupts with priority <7 for
; next 5 instructions
; Write the 0x55 key
; Write the 0xAA key
; Initiate program sequence
The write does not initiate if the above sequence is not
exactly followed (write 0x55 to NVMKEY, write 0xAA to
NVMCON, then set WR bit) for each word. It is strongly
recommended that interrupts be disabled during this
code segment.
Additionally, the WREN bit in NVMCON must be set to
enable writes. This mechanism prevents accidental
writes to data EEPROM due to unexpected code exe-
cution. The WREN bit should be kept clear at all times
except when updating the EEPROM. The WREN bit is
not cleared by hardware.
After a write sequence has been initiated, clearing the
WREN bit does not affect the current write cycle. The
WR bit is inhibited from being set unless the WREN bit
is set. The WREN bit must be set on a previous instruc-
tion. Both WR and WREN cannot be set with the same
instruction.
At the completion of the write cycle, the WR bit is
cleared in hardware and the Nonvolatile Memory Write
Complete Interrupt Flag bit (NVMIF) is set. The user
may either enable this interrupt or poll this bit. NVMIF
must be cleared by software.
6.3.1
Once the user has erased the word to be programmed,
then a table write instruction is used to write one write
latch, as shown in Example 6-4.
6.3.2
To write a block of data EEPROM, write to all sixteen
latches first, then set the NVMCON register and
program the block.
WRITING A WORD OF DATA
EEPROM
WRITING A BLOCK OF DATA
EEPROM
DS70139E-page 55

Related parts for DSPIC30F2012