dsPIC33EVXXXGM00X/10X FAMILY
5.2 RTSP Operation
RTSP allows the user application to erase a single
page of memory, program a row and to program two
instruction words at a time. See Table 1 in the
“dsPIC33EVXXXGM00X/10X Product Families”
section for the page sizes of each device.memory array
is organized into rows of 64 instructions or 192 bytes.
RTSP allows the user application to era
The Flash program memory array is organized into
rows of 64 instructions or 192 bytes. RTSP allows the
user application to erase a page of program memory,
which consists of eight rows (512 instructions) at a
time, and to program one row or two adjacent words at
a time. The 8-row erase pages and single row write
rows are edge-aligned, from the beginning of program
memory, on boundaries of 1536 bytes and 192 bytes,
respectively. Table 30-13 in Section 30.0 “Electrical
Characteristics” lists the typical erase and
programming times.
The basic sequence for RTSP word programming is to
use the TBLWTL and TBLWTH instructions to load two of
the 24-bit instructions into the write latches found in
configuration memory space. See Figure 4-1 to
Figure 4-5 for write latch addresses. Programming is
performed by unlocking and setting the control bits in
the NVMCON register.
Row programming is performed by loading 192 bytes
into data memory and then loading the address of the
first byte in that row into the NVMSRCADR register.
Once the write has been initiated, the device will auto-
matically load the write latches and increment the
NVMSRCADR and the NVMADR(U) registers until all
bytes have been programmed. The RPDF bit
(NVMCON<9>) selects the format of the stored data in
RAM to be either compressed or uncompressed. See
Figure 5-2 for data formatting. Compressed data helps
to reduce the amount of required RAM by using the
upper byte of the second word for the MSB of the second
instruction.
For more information on erasing and programming the
Flash memory, refer to “Flash Programming”
(DS70609) in the “dsPIC33/PIC24 Family Reference
Manual”.
Note 1: Before reprogramming either of the two
words in a double-word pair, the user
must erase the Flash memory page in
which it is located.
2: Before reprogramming any word in a row,
the user must erase the Flash memory
page in which it is located.
FIGURE 5-2:
UNCOMPRESSED/
COMPRESSED FORMAT
15
7
0
LSW1
0x00
MSB1
Even Byte
Address
LSW2
0x00
MSB2
UNCOMPRESSED FORMAT (RPDF = 0)
15
7
LSW1
MSB2
MSB1
LSW2
0
Even Byte
Address
COMPRESSED FORMAT (RPDF = 1)
5.3 Programming Operations
A complete programming sequence is necessary for
programming or erasing the internal Flash in RTSP
mode. The processor stalls (waits) until the program-
ming operation is finished. Setting the WR bit
(NVMCON<15>) starts the operation and the WR bit is
automatically cleared when the operation is finished.
5.3.1
PROGRAMMING ALGORITHM FOR
FLASH PROGRAM MEMORY
Programmers can program two adjacent words
(24 bits x 2) of program Flash memory at a time on
every other word address boundary (0x000002,
0x000006, 0x00000A, etc.). To do this, erase the page
that contains the desired address of the location the
user wants to change. For protection against accidental
operations, the write initiate sequence for NVMKEY
must be used to allow any erase or program operation
to proceed. After the programming command has been
executed, the user application must wait for the
programming time until programming is complete. The
two instructions following the start of the programming
sequence should be NOPs.
Refer to “Flash Programming” (DS70609) in the
“dsPIC33/PIC24 Family Reference Manual” for details
and code examples on programming using RTSP.
DS70005144E-page 84
2013-2016 Microchip Technology Inc.