English
Language : 

PIC32MX795F512L-80IPT Datasheet, PDF (36/68 Pages) Microchip Technology – PIC32 Flash Programming Specification
PIC32
16.2.5 PROGRAM COMMAND
The PROGRAM command instructs the PE to program
Flash memory, including Configuration Words, starting
from the 32-bit address specified in the Addr_Low and
Addr_High fields. A 32-bit length field specifies the
number of bytes to program.
The address must be aligned to a Flash row size
boundary and the length must be a multiple of a Flash
row size. Flash row sizes are either 32 words (128
bytes) or 128 words (512 bytes). Please refer to
Table 5-1.
FIGURE 16-7:
31
15
31
15
31
15
31
15
31
15
PROGRAM COMMAND
16
Op code
0
Operand
16
Addr_High
0
Addr_Low
16
Length_High
0
Length_Low
16
Data_High_1
0
Data_Low_1
16
Data_High_N
0
Data_Low_N
TABLE 16-6: PROGRAM FORMAT
Field
Description
Op code
0x2
Operand
Addr_Low
Addr_High
Length_Low
Length_High
Data_Low_N
Data_High_N
Not used
Low 16 bits of 32-bit destination
address
High 16 bits of 32-bit destination
address
Low 16 bits of Length
High 16 bits Length
Low 16 bits data word 2 through N
High 16 bits data word 2 through N
There are three programming scenarios:
1. The length of the data to be programmed is the
size of a single flash row.
2. The length of the data to be programmed is the
size of two flash rows.
3. The length of the data to be programmed is
larger than the size of two flash rows.
When the data length is equal to 512 bytes, the PE
receives the 512-byte block of data from the probe and
immediately sends the response for this command
back to the probe.
The PE will respond for each row of data that it
receives. If the data length of the command is equal to
a single row, a single PE response is generated. If the
data length is equal to two rows, the PE waits to
receive both rows of data, and then sends back-to-
back responses for each data row. If the data length is
greater than two rows of data, the PE will send the
response for the first row after receiving the first two
rows of data. Subsequent responses are sent after
receiving subsequent data row packets. The
responses will lag the data by one row. When the last
row of data is received the PE will respond with back-
to-back responses for the second-to-last data row
followed by the last row.
If the PE encounters an error in programming any of
the blocks, it sends a failure status to the probe and
aborts the PROGRAM command. On receiving the failure
status, the probe must stop sending data. The PE will
not process any other data for this command from the
probe. The process is illustrated in Figure 16-9.
Note:
If the PROGRAM command fails, the
programmer should read the failing row
using the READ command from the Flash
memory. Next, the programmer should
compare the row received from Flash
memory to its local copy, word-by-word, to
determine the address where Flash
programming fails.
The response for this command is a little different than
the response for other commands. The 16 MSbs of the
response contain the 16 LSbs of the destination
address, where the last block is programmed. This
helps the probe and the PE maintain proper
synchronization of sending, and receiving, data and
responses.
Expected Response (1 word):
FIGURE 16-8:
PROGRAM RESPONSE
31
16
LSB 16 bits of the destination address of last block
15
0
Response Code
DS61145L-page 36
 2007-2013 Microchip Technology Inc.