PIC32-Flash-Programming-Specification-DS60001145
PIC32-Flash-Programming-Specification-DS60001145
No
Done
Yes
Verify Device
Done
1.8V(1) 3.3V(1)
VSS
PIC32MZ DA
VDDIO
VBAT Note 1: These are typical operating voltages. Refer to
Section 21.0 “AC/DC Characteristics and Timing
VDDCORE and VDDR1V8 Requirements” for the full operating ranges of VDD
VSS1V8 and VBAT.
VSS
3.3V(1)
PIC32MK
VDD
VBAT
VSS
TMS Common
TCK VDD/VDDIO/VDD1V8CORE
ETAP CPU VBAT/VDDR1V8
TDI VSS/VSS1V8
TDO Flash
MTAP
Controller MCLR
or
TCK
TCK
TDO 1 X
PGECx
TCK
TDO 1 X
PGECx
5.3.3 SYNCHRONIZATION When asserting the PGEDx pin high, there may be
contention on the pin as the device may attempt to
Some PIC32 devices can Reset the internal EJTAG
drive TDO out onto the pin while the in-circuit emulator
state machine if the attached programmer loses syn-
is driving in. This will only occur for a maximum of one
chronization with it. This can occur when noise is pres-
cycle as TMS high will advance the EJTAG state
ent on the PGCx signal.
machine out of a Shift-IR or Shift-DR state.
To achieve resynchronization, the PGEDx pin is held
Synchronization in 2-wire, 2-phase mode is not
high for 24 PGECx clock cycles. This forces five TMS
supported.
events into the EJTAG controller and will place the
EJTAG state machine into a Test Idle Reset. See
Figure 5-6 for an example of how to achieve
resynchronization.
PGECx 1 4 5 21 22 23 24
§
2 3
§
PGEDx
TDO Contention Synchronization achieved
Mode = 6’b011111
TCK
TDI
TDO
Mode = 6’b011111
PGECx
Command (MSb)
TMS Header = 1100 Command = 5’h0x07 + TMS = 1 TMS Footer = 10
TCK
TDO 1 x
TMS Header = 1100 Command (5’h0x07) + TMS = 0 Command (MSb) + TMS = 1 TMS Footer = 10
PGECx
PGEDx
TDI = 0 TMS = 1 TDO = x TDI = iLSb TMS = 0 TDO = x TDI = iMSb TMS = 1 TDO = x TDI = 0 TMS = 1 TDO = x
TCK
PGEC
PGED TDI = 0 TMS = 1 TDO = X TDI = 0 TMS = 0 TDO = X TDI = 0 TMS = 0 TDO = oLSb
TMS Footer = 10
TCK
PGECx
PGEDx TDI = X TMS = 1 TDI = 0 TMS = 0 TDI = TMS = 0 TDI = TMS = 1 TDI = X TMS = 1
iLSb MSb
PGECx
PGEDx TDI = 0 TMS = 1 TDO = X TDI = 0 TMS = 0 TDO = X TDI = 0 TMS = 0 TDO = oPrAcc
TDI = 0 TMS = 0 TDO = oLSb TDI = iLSb TMS = 0 TDO = oLSb+1 TDI = iMSb TMS = 1 TDO = X
TMS Footer = 10
// Read data
XferInstruction(0x8d090000); // lw t1, 0(t0)
return oData;
PGECx 1 4 5 21 22 23 24
§
2 3
§
PGEDx
TDO Contention Synchronization achieved
P20
P6
P19 P7
P14
VIH VIH
MCLR
VDD
Program/Verify Entry Code = 0x4D434850
PGEDx 0 1 0 0 1 ... 0 0 0 0
b31 b30 b29 b28 b27 b3 b2 b1 b0
PGECx
P18 P1A
P1B
No Cannot Enter
CPS = 1
Must Erase First
Yes
Assert Reset
2-wire
XferData (MCHP_ASSERT_RST)
Select ETAP
SendCommand (MTAP_SW_ETAP)
SetMode (6’b011111)
SetMode (6’b011111)
Release Reset
XferData (MCHP_DE_ASSERT_RST)
Enable Flash
XferData (MCHP_FLASH_EN)
Required for PIC32MX devices
Select ETAP
SendCommand (MCHP_SW_ETAP)
SetMode (6’b011111)
2-wire
Increment bufAddr
No
Done
Note 1: For programming the Flash at runtime in the users application, the following code is recommended:
Once a row of data has been downloaded into the Unlock Flash Controller
device’s SRAM, the programming sequence must be
initiated to write the block of data to the Flash memory.
Start Operation
See Table 14-1 for the op code and instructions for
initiating a Flash row write.
Done
14.1 With the PE
When using the PE, the data is immediately written to
the Flash memory from the SRAM. No further action is In the Flash write procedure (see Table 14-1), the Row
required. Programming method is used to program the Flash
memory, as it is typically the most expedient. word and
Quad Word programming methods are also available,
depending on the device, and may be used or required
depending on your application. Refer to the “Flash
Program Memory” chapter in the specific device data
sheet and the related section of the “PIC32 Family
Reference Manual” for more information.
The following steps are required to initiate a Flash
write:
1. XferInstruction (op code).
2. Repeat Step 1 until the last instruction is
transferred to the CPU.
P16 PGECx
MCLR
PGEDx = Input
VDD/VDDIO
17.2.1 COMMAND FORMAT The command in the op code field must match one of
the commands in the command set that is listed in
All PE commands have a general format consisting of Table 17-2. Any command received that does not
a 32-bit header and any required data for the match a command the list returns a NACK response,
command, see Figure 17-1. The 32-bit header consists as shown in Table 17-3.
of a 16-bit op code field, which is used to identify the
command, and a 16-bit command Operand field. Use The PE uses the command Operand field to determine
of the Operand field varies by command. the number of bytes to read from or to write to. If the
value of this field is incorrect, the command is not be
Note: Some commands have no Operand properly received by the PE.
information; however, the Operand field
must be sent and the programming
executive will ignore the data.
Expected Response: 31 16
Data_High_N
FIGURE 17-6: READ RESPONSE 15 0
31 16 Data_Low_N
Last Command
15 0 TABLE 17-6: PROGRAM FORMAT
Response Code Field Description
31 16 Op code 0x2
Data_High_1
Operand Not used
15 0
Addr_Low Low 16 bits of 32-bit destination
Data_Low_1 address
31 16 Addr_High High 16 bits of 32-bit destination
Data_High_N address
15 0 Length_Low Low 16 bits of Length
Data_Low_N Length_High High 16 bits Length
Data_Low_N Low 16 bits data word 2 through N
Note: Reading unimplemented memory will Data_High_N High 16 bits data word 2 through N
cause the PE to Reset. Ensure that only
memory locations present on a particular
device are accessed.
Start
Receive status
(LSB 16 bits of Send second row Send second row
Destination Address of data of data
Status Value)
Receive status
for Row 2
Receive status
for Row N-1
Receive status
for Row N
Done
Op code 0x8
Operand Not used
Address Address where to start calculating the
CRC
Length Length of buffer on which to calculate
the CRC, in number of bytes
31 16 Op code 0x10
Op code Operand Not used
15 0 Addr_High High-order 16 bits of the 32-bit starting
address.
Operand
Addr_Low Low-order 16 bits of the 32-bit starting
31 16
address.
Addr_High
Data0_High High-order 16 bits of data word 0.
15 0
Data0_Low Low-order 16 bits of data word 0.
Addr_Low
Data1_High High-order 16 bits of data word 1.
31 16
Data1_Low Low-order 16 bits of data word 1.
Data0_High
Data2_High High-order 16 bits of data word 2.
15 0
Data2_Low Low-order 16 bits of data word 2.
Data0_Low
Data3_High High-order 16 bits of data word 3.
31 16
Data3_Low Low-order 16 bits of data word 3.
Data1_High
Data4_High High-order 16 bits of data word 4.
15 0
Data4_Low Low-order 16 bits of data word 4.
Data1_Low
Data5_High High-order 16 bits of data word 5.
31 16
Data5_Low Low-order 16 bits of data word 5.
Data2_High
Data6_High High-order 16 bits of data word 6.
15 0
Data6_Low Low-order 16 bits of data word 6.
Data2_Low
Data7_High High-order 16 bits of data word 7.
31 16
Data7_Low Low-order 16 bits of data word 7.
Data3_High
Expected Response (1 word):
15 0
Data3_Low FIGURE 17-33: QUAD_DOUBLE_WORD_PROGRAM
31 16 RESPONSE
Data4_High 31 16
15 0 Last Command
Data4_Low 15 0
31 16 Response Code
Data5_High
15 0
Data5_Low
31 16
Data6_High
15 0
Flash
Device Family Memory DEVCFG0 DEVCFG1 DEVCFG2 DEVCFG3 DEVCFG4 DEVID
Sizes (KB)
PIC32MX110/120/130/
150F0xx
PIC32MX150F128 16, 32, 64,
0x1100FC1F 0x03DFF7A7 0x00070077 0xF000FFFF — 0x0FFFFFFF
(28/36/44-pin devices 128
only)
PIC32MX130F128/256
PIC32MX150F256
16, 32, 64,
(28/36/44-pin devices 0x1100FC1F 0x03DFF7A7 0x00070077 0xF0000000 — 0x0FFFFFFF
128
only)
PIC32MX210/220/230/
16, 32, 64,
250 (28/36/44-pin 0x1100FC1F 0x03DFF7A7 0x00078777 0xF0000000 — 0x0FFFFFFF
128
devices only)
PIC32MX15X/17X (28/
128, 256 0x1187F01F 0x03FFF7A7 0xFFB700F7 0x30C00000 — 0x0FFFFFFF
44-pin devices only)
PIC32MX25X/27X (28/
128, 256 0x1187F01F 0x03FFF7A7 0xFFB787F7 0x70C00000 — 0x0FFFFFFF
44-pin devices only)
PIC32MX320/340/360 32, 64, 128,
0x110FF00B 0x009FF7A7 0x00070077 0x0000FFFF — 0x000FF000
256, 512
PIC32MX420/440/460 32, 64, 128,
0x110FF00B 0x009FF7A7 0x00078777 0x0000FFFF — 0x000FF000
256, 512
PIC32MX110/120/130/
150F0xx
PIC32MX150F128 64, 128, 256, 0xF000FFFF
0x110FFC1F 0x03DFF7A7 0x00070077 — 0x0FFFFFFF
PIC32MX170F256 512
(64/100-pin Devices
only)
PIC32MX130F128/256
PIC32MX150F256
64, 128, 256,
PIC32MX170F512 0x110FFC1F 0x03DFF7A7 0x00070077 0xF0000000 — 0x0FFFFFFF
512
(64/100-pin devices
only)
PIC32MX230F0xx
PIC32MX250F128
64, 128, 256,
PIC32MX270F256 0x110FFC1F 0x03DFF7A7 0x00078777 0xF000FFFF — 0x0FFFFFFF
512
(64/100-pin devices
only)
Note 1: Applicable only to the PIC32MZ DA family of devices.
2: Device Configuration register mask values of PIC32MZ for:
• USERID: 0x0000FFF
• BCFG0: 0x8000000B
pic32_checksum
Yes
Done
Where,
PF = 32-bit summation of all bytes in Program Flash
BF = 32-bit summation of all bytes in Boot Flash, except device Configuration registers (see Note 1)
y
DCR = 32-bit summation of bytes MASK DEVCFGX & DEVCFGx
X = 0
Where,
y = 3 for PIC32MX, PIC32MKXXXXGPD/GPE/MCFXXX, PIC32MZ EC and PIC32MZ EF family of devices
y = 4 for all other PIC32MZ family of devices
Note 1: For the PIC32MZ family of devices, the Boot Flash memory that resides at 0x1FCxFF00 through
0x1FCxFFFF is not summed, as these memory locations contain the device configuration and CP
values. For PIC32MKXXXXGPD/GPE/MCFXXX family of devices, the Boot Flash memory that
resides at 0x1FC03F00 through 0x1FC03FFF is not summed.
2: For PIC32MZ and PIC32MKXXXXGPD/GPE/MCFXXX family of devices, the checksum calculated
in MPLAB X IDE only uses the primary DEVCFGx registers. Neither the alternate nor second Boot
Flash (if available) registers are calculated.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For descriptions of these bits, please refer to the Imagination Technologies Limited web site.
(www.imgtec.com).
Param.
Symbol Characteristic Min. Max. Units Conditions
No.
D111 VDDIO Supply Voltage During Programming — — V See Note 1
D112a VDDCORE Core Power Supply Voltage During Programming — — V See Note 1
D112b VDDR1V8 DDR SDRAM Supply Voltage During Programming — — V See Note 1
D113 IDDP Supply Current During Programming — — mA See Note 1
D114 IPEAK Instantaneous Peak Current During Start-up — — mA See Note 1
D115a IDDCORE Core Power Supply Current During Programming — — mA See Note 1
D115b IDDR1V8P DDR SDRAM Supply Current During Programming — — mA See Note 1
D116 VDDVBAT VBAT Supply Voltage During Programming — — V See Note 1
D117 IDDVBAT VBAT Supply Current During Programming — — mA See Note 1
D031 VIL Input Low Voltage — — V See Note 1
D041 VIH Input High Voltage — — V See Note 1
D080 VOL Output Low Voltage — — V See Note 1
D090 VOH Output High Voltage — — V See Note 1
D012 CIO Capacitive Loading on I/O pin (PGEDx) — — pF See Note 1
D013 CF Filter Capacitor Value on VCAP — — F See Note 1
P1 TPGC Serial Clock (PGECx) Period 100 — ns —
P1A TPGCL Serial Clock (PGECx) Low Time 40 — ns —
P1B TPGCH Serial Clock (PGECx) High Time 40 — ns —
P6 TSET2 VDD Setup Time to MCLR 100 — ns —
P7 THLD2 Input Data Hold Time from MCLR 500 — ns —
P9a TDLY4 PE Command Processing Time 40 — s —
Delay between PGEDx by the PE to PGEDx
P9b TDLY5 15 — s —
Released by the PE
P11 TDLY7 Chip Erase Time — — ms See Note 1
P12 TDLY8 Page Erase Time — — ms See Note 1
P13 TDLY9 Row Programming Time — — ms See Note 1
P14 TR MCLR Rise Time to Enter ICSP™ mode — 1.0 s —
P15 TVALID Data Out Valid from PGECx 10 — ns —
P16 TDLY8 Delay between Last PGECx and MCLR 0 — s —
P17 THLD3 MCLR to VDD — 100 ns —
Delay from First MCLR to First PGECx for Key
P18 TKEY1 40 — ns —
Sequence on PGEDx
Delay from Last PGECx for Key Sequence on
P19 TKEY2 40 — ns —
PGEDx to Second MCLR
P20 TMCLRH MCLR High Time — 500 µs —
Note 1: Refer to the “Electrical Characteristics” chapter in the specific device data sheet for the Minimum and
Maximum values for this parameter.
• Microchip believes that its family of products is secure when used in the intended manner and under normal conditions.
• There are dishonest and possibly illegal methods being used in attempts to breach the code protection features of the Microchip
devices. We believe that these methods require using the Microchip products in a manner outside the operating specifications
contained in Microchip's Data Sheets. Attempts to breach these code protection features, most likely, cannot be accomplished
without violating Microchip's intellectual property rights.
• Microchip is willing to work with any customer who is concerned about the integrity of its code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of its code. Code protection does not
mean that we are guaranteeing the product is "unbreakable." Code protection is constantly evolving. We at Microchip are
committed to continuously improving the code protection features of our products. Attempts to break Microchip's code protection
feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or
other copyrighted work, you may have a right to sue for relief under that Act.