dspic33e/pic24e flash programming...

54
© 2009-2011 Microchip Technology Inc. DS70619B-page 1 dsPIC33E/PIC24E 1.0 DEVICE OVERVIEW This document defines the programming specification for the dsPIC33E 16-bit Digital Signal Controller (DSC) and PIC24E 16-bit Microcontroller (MCU) families. This programming specification is required only for those developing programming support for the dsPIC33E/ PIC24E family. All other customers should use development tools that already provide support for device programming. Topics covered include: Section 1.0 “Device Overview” Section 2.0 “Programming Overview of the dspic33e/PIC24E” Section 3.0 “Device Programming – Enhanced ICSP” Section 4.0 “Checksum Computation” Section 5.0 “The Programming Executive” Section 6.0 “Device Programming – ICSP” Section 7.0 “Programming the Programming Executive to Memory” Section 8.0 “Device ID” Section 9.0 “AC/DC Characteristics and Timing Requirements” Appendix A: “Hex File Format” Appendix B: “Revision History” 2.0 PROGRAMMING OVERVIEW OF THE dsPIC33E/PIC24E There are two methods of programming the dsPIC33E/ PIC24E family of devices discussed in this programming specification. They are: In-Circuit Serial Programming™ (ICSP™) programming capability Enhanced In-Circuit Serial Programming The ICSP programming method is the most direct method to program the device; however, it is also the slower of the two methods. It provides native, low-level programming capability to erase, program and verify the chip. The Enhanced ICSP protocol uses a faster method that takes advantage of the programming executive, as illustrated in Figure 2-1. The programming executive provides all the necessary functionality to erase, program and verify the chip through a small command set. The command set allows the programmer to program the dsPIC33E/PIC24E Programming Specification devices without having to deal with the low-level programming protocols of the chip. FIGURE 2-1: PROGRAMMING SYSTEM OVERVIEW FOR ENHANCED ICSP™ This specification is divided into major sections that describe the programming methods independently. Section 3.0 “Device Programming – Enhanced ICSP” describes the Enhanced ICSP method. Section 6.0 “Device Programming – ICSP” describes the ICSP method. dsPIC33E/PIC24E Programmer Programming Executive On-Chip Memory dsPIC33E/PIC24E Flash Programming Specification

Upload: others

Post on 13-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24EdsPIC33E/PIC24E Flash Programming Specification

1.0 DEVICE OVERVIEWThis document defines the programming specificationfor the dsPIC33E 16-bit Digital Signal Controller (DSC)and PIC24E 16-bit Microcontroller (MCU) families. Thisprogramming specification is required only for thosedeveloping programming support for the dsPIC33E/PIC24E family. All other customers should usedevelopment tools that already provide support fordevice programming.

Topics covered include:

• Section 1.0 “Device Overview”• Section 2.0 “Programming Overview of the

dspic33e/PIC24E”• Section 3.0 “Device Programming – Enhanced

ICSP”• Section 4.0 “Checksum Computation”• Section 5.0 “The Programming Executive”• Section 6.0 “Device Programming – ICSP”• Section 7.0 “Programming the Programming

Executive to Memory”• Section 8.0 “Device ID”• Section 9.0 “AC/DC Characteristics and

Timing Requirements”• Appendix A: “Hex File Format”• Appendix B: “Revision History”

2.0 PROGRAMMING OVERVIEW OF THE dsPIC33E/PIC24E

There are two methods of programming the dsPIC33E/PIC24E family of devices discussed in thisprogramming specification. They are:

• In-Circuit Serial Programming™ (ICSP™) programming capability

• Enhanced In-Circuit Serial Programming

The ICSP programming method is the most directmethod to program the device; however, it is also theslower of the two methods. It provides native, low-levelprogramming capability to erase, program and verifythe chip.

The Enhanced ICSP protocol uses a faster method thattakes advantage of the programming executive, asillustrated in Figure 2-1. The programming executiveprovides all the necessary functionality to erase,program and verify the chip through a small commandset. The command set allows the programmer toprogram the dsPIC33E/PIC24E ProgrammingSpecification devices without having to deal with thelow-level programming protocols of the chip.

FIGURE 2-1: PROGRAMMING SYSTEM OVERVIEW FOR ENHANCED ICSP™

This specification is divided into major sections thatdescribe the programming methods independently.Section 3.0 “Device Programming – EnhancedICSP” describes the Enhanced ICSP method.Section 6.0 “Device Programming – ICSP” describesthe ICSP method.

dsPIC33E/PIC24E

Programmer ProgrammingExecutive

On-Chip Memory

© 2009-2011 Microchip Technology Inc. DS70619B-page 1

Page 2: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

2.1 Required ConnectionsThese devices require specific connections forprogramming to take place. These connections includepower, VCAP, MCLR, and one programming pair(PGEDx/PGECx). Table 2-1 describes theseconnections (refer to the specific device data sheet forpin descriptions and power connection requirements).

TABLE 2-1: PINS USED DURING PROGRAMMING

2.2 Program Memory Write/Erase Requirements

The program Flash memory on the dsPIC33E/PIC24Ehas a specific write/erase requirement that must beadhered to for proper device operation. The rule is thatany given word in memory must not be written withoutfirst erasing the page in which it is located. Thus, theeasiest way to conform to this rule is to write all the datain a programming block within one write cycle. Theprogramming methods specified in this documentcomply with this requirement.

2.3 Memory MapThe program memory map extends from 0x0 to0xFFFFFE. Code storage is located at the base of thememory map and supports up to 175,104 instructions(about 512 Kbytes). Table 2-2 shows the programmemory size and number of erase and program blockspresent in each device variant. Each erase block orpage contains 1024 instructions and each programblock or row, contains 128 instructions.

An additional 24 Kbytes of program Flash memory isavailable at locations 0x7FC000 through 0x7FFFFF,which is called auxiliary program Flash memory.

Locations 0x800000 through 0x800FFE are reservedfor executive code memory. This region stores theprogramming executive and the debugging executive.The programming executive is used for device pro-gramming and the debug executive is used for in-circuitdebugging. This region of memory cannot be used tostore user code.

Locations 0xF80000 through 0xF80013 are reservedfor the device Configuration registers.

Locations 0xFF0000 and 0xFF0002 are reserved forthe Device ID Word registers. These bits can be usedby the programmer to identify which device type isbeing programmed. They are described in Section 8.0“Device ID”. The Device ID registers read outnormally, even after code protection is applied.

Figure 2-2 shows the memory map for the dsPIC33E/PIC24E family variants.

Note: Refer to the specific device data sheet forcomplete pin diagrams of dsPIC33E/PIC24E devices.

During Programming

Pin Name Pin Type Pin Description

MCLR I Programming EnableVDD, VUSB, and AVDD

P Power Supply(1)

VSS and AVSS P Ground(1)

VCAP P CPU Logic Filter Capacitor Connection

PGECx I Programming Pin Pair: Serial Clock

PGEDx I/O Programming Pin Pair: Serial Data

Legend: I = Input O = Output P = PowerNote 1: All power supply and ground pins must be

connected including AVDD, VUSB, and AVSS.

Note: A program memory word can beprogrammed twice before an erase, butonly if (a) the same data is used in bothprogram operations or (b) bits containing‘1’ are set to ‘0’ but no ‘0’ is set to ‘1’.

DS70619B-page 2 © 2009-2011 Microchip Technology Inc.

Page 3: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

TABLE 2-2: CODE MEMORY SIZE

dsPIC33E/PIC24E Device

User Memory Address Limit

(Instruction Words)

Write Blocks

Erase Blocks

Auxiliary Memory Address Limits

(Instruction Words)

Executive Memory Address Limit

(Instruction Words)

dsPIC33EP256MU806 0x02ABFE (87552) 684 86 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

dsPIC33EP256MU810 0x02ABFE (87552) 684 86 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

dsPIC33EP256MU814 0x02ABFE (87552) 684 86 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

PIC24EP256GU810 0x02ABFE (87552) 684 86 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

PIC24EP256GU814 0x02ABFE (87552) 684 86 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

dsPIC33EP512GP806 0x0557FE (175104) 1368 171 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

dsPIC33EP512MC806 0x0557FE (175104) 1368 171 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

dsPIC33EP512MU810 0x0557FE (175104) 1368 171 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

dsPIC33EP512MU814 0x0557FE (175104) 1368 171 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

PIC24EP512GP806 0x0557FE (175104) 1368 171 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

PIC24EP512GU810 0x0557FE (175104) 1368 171 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

PIC24EP512GU814 0x0557FE (175104) 1368 171 0x7FC000-0x7FFFFE (8K) 0x800000-0x800FFE (2K)

© 2009-2011 Microchip Technology Inc. DS70619B-page 3

Page 4: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

FIGURE 2-2: PROGRAM MEMORY MAP

0x0000000x000002

0x7FFFFE

0xF800000xF800120xF80014

0xFEFFFE0xFF00000xFF0002

0xF7FFFE

0x000004

0x7FFFFC

0x0002000x0001FE

Con

figur

atio

n M

emor

y Sp

ace

Use

r Mem

ory

Spac

e

Note 1: Memory areas are not shown to scale.2: Reset location is controlled by the Reset Target Vector Select bit (RSTPRI). Refer to the “Special

Features” section in the specific device data sheet for more information.

Reset Address(2)

Device Configuration

User ProgramFlash Memory

(87552 instructions)

Registers

DEVID (2 Words)

Unimplemented(Read ‘0’s)

GOTO Instruction(2)

Reserved

Reserved

Interrupt Vector Table

dsPIC33EP256MU806/810/814 and

Reset Address(2)

Device Configuration

User ProgramFlash Memory

(175104 instructions)

Registers

DEVID (2 Words)

Unimplemented(Read ‘0’s)

GOTO Instruction(2)

Reserved

Reserved

Interrupt Vector Table

dsPIC33EP512MU810/814,

0x0558000x0557FE

0x02AC000x02ABFE

Reserved Reserved

0xFFFFFE

0x7FFFFA

0x7FC000Flash Memory

Auxiliary Program

PIC24EP256GU810/814PIC24EP512GU810/814,

GOTO Instruction(2)

Flash Memory

0x800000

Auxiliary Program

Reset Address(2)

GOTO Instruction(2)

Reset Address(2)

Reserved Reserved

Write Latch Write Latch

0xF9FFFE0xFA0000

0xFA00FE0xFA0100

VectorAuxiliary Interrupt

VectorAuxiliary Interrupt

0x7FFFF8

0x7FBFFE

dsPIC33EP512GP/MC806,

and PIC24EP512GP806

Executive Code Memory(2048 x 24-bit)

Executive Code Memory(2048 x 24-bit) 0x800FFE

0x801000

DS70619B-page 4 © 2009-2011 Microchip Technology Inc.

Page 5: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

3.0 DEVICE PROGRAMMING – ENHANCED ICSP

This section discusses programming the devicethrough Enhanced ICSP and the programmingexecutive. The programming executive resides inexecutive memory (separate from code memory) and isexecuted when Enhanced ICSP Programming mode isentered. The programming executive provides themechanism for the programmer (host device) toprogram and verify the dsPIC33E/PIC24EProgramming Specification family devices using asimple command set and communication protocol.There are several basic functions provided by theprogramming executive:

• Read Memory• Erase Memory• Program Memory• Blank Check• Read Executive Firmware Revision

The programming executive performs the low-leveltasks required for erasing, programming and verifyinga device. This allows the programmer to program thedevice by issuing the appropriate commands and data.Table 3-1 summarizes the commands. A detaileddescription for each command is provided inSection 5.2 “Programming Executive Commands”.

TABLE 3-1: COMMAND SET SUMMARY

The programming executive uses the device’s dataRAM for variable storage and program execution. Afterthe programming executive is run, no assumptionsshould be made about the contents of data RAM.

3.1 Overview of the Programming Process

Figure 3-1 shows the high-level overview of theprogramming process. After entering Enhanced ICSPmode, the programming executive is verified. Next, thedevice is erased, and then, the program Flash memory(primary and auxiliary Flash memory) is programmed,followed by the non-volatile device Configurationregisters. Code memory (including the Configurationregisters) is then verified to ensure that programmingwas successful.

After the programming executive has been verifiedin memory (or loaded if not present), the dsPIC33E/PIC24E Programming Specification can beprogrammed using the command set shown inTable 3-1.

FIGURE 3-1: HIGH-LEVEL ENHANCED ICSP™ PROGRAMMING FLOW

Command Description

SCHECK Sanity check.READC Read Configuration registers or Device

ID registers.READP Read primary Flash or auxiliary Flash

memory. PROGC Program a Configuration register and

verify.PROGP Program one row of code memory and

verify.ERASEB Bulk Erase the device.ERASEBP Erase entire primary program Flash

memory.ERASEBA Erase entire auxiliary Flash memory.ERASEP Erase Page command.CRCP Performs CRC on memory.QBLANK Query to check whether code memory

is blank.QVER Query the software version.

Start

End

Perform BulkErase

Program Memory

Verify Program

Enter Enhanced ICSP™

Program Configuration Bits

Verify Configuration Bits

Exit Enhanced ICSP

© 2009-2011 Microchip Technology Inc. DS70619B-page 5

Page 6: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

3.2 Confirming the Presence of the Programming Executive

Before programming, the programmer must confirmthat the programming executive is stored in executivememory. The procedure for this task is shown inFigure 3-2.

First, ICSP mode is entered. Then, the uniqueApplication ID Word stored in executive memory is read.If the programming executive is resident, the correctApplication ID Word is read and programming canresume as normal. However, if the Application ID Word isnot present, the programming executive must beprogrammed to executive code memory using themethod described in Section 7.0 “Programming theProgramming Executive to Memory”. SeeTable 8-1for the Application ID of each device.

Section 6.0 “Device Programming – ICSP” describesthe ICSP programming method. Section 6.11 “Readingthe Application ID Word” describes the procedure forreading the Application ID Word in ICSP mode.

FIGURE 3-2: CONFIRMING PRESENCE OF PROGRAMMING EXECUTIVE

3.3 Entering Enhanced ICSP ModeAs shown in Figure 3-3, entering Enhanced ICSP Program/Verify mode requires three steps:

1. The MCLR pin is briefly driven high then low.2. A 32-bit key sequence is clocked into PGD.3. MCLR is then driven high within a specified

period of time and held.

The programming voltage applied to MCLR is VIH,which is essentially VDD in case of dsPIC33E/PIC24Edevices. There is no minimum time requirement forholding at VIH. After VIH is removed, an interval of atleast P18 must elapse before presenting the keysequence on PGD.

The key sequence is a specific 32-bit pattern,‘0100 1101 0100 0011 0100 1000 0101 0000’(more easily remembered as 0x4D434850 inhexadecimal format). The device will enter Program/Verify mode only if the key sequence is valid. The MostSignificant bit (MSb) of the most significant nibble mustbe shifted in first.

Once the key sequence is complete, VIH must beapplied to MCLR and held at that level for as long asProgram/Verify mode is to be maintained. An intervaltime of at least P19, P7, and P1*5 must elapse beforepresenting data on PGD. Signals appearing on PGDbefore this time has elapsed will not be interpreted asvalid.

On successful entry, the program memory can beaccessed and programmed in serial fashion. While inthe Program/Verify mode, all unused I/Os are placed inthe high-impedance state.

Is

Start

Enter ICSP™ Mode

Application IDpresent?(1)

Yes

No

Application IDCheck the

be ProgrammedProg. Executive must

by reading Address0x8007F0

End

Exit ICSP™ Mode

Enter Enhanced

Sanity Check

Note 1: See Table 8-1 for the Application ID ofeach device.

ICSP™ Mode

DS70619B-page 6 © 2009-2011 Microchip Technology Inc.

Page 7: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

FIGURE 3-3: ENTERING ENHANCED ICSP™ MODE

3.4 Blank CheckThe term “Blank Check” implies verifying that thedevice has been successfully erased and has noprogrammed memory locations. A blank or erasedmemory location is always read as ‘1’, except for theGSSK<1:0> and APLK<1:0> bits in the FGS and FASConfiguration registers, which read as ‘0’ when in ablank (erased) state.

The Device ID registers (0xFF0000:0xFF0002) can beignored by the Blank Check since this region storesdevice information that cannot be erased. The deviceConfiguration registers are also ignored by the BlankCheck. Additionally, all unimplemented memory spaceshould be ignored from the Blank Check.

The QBLANK command is used for the Blank Check. Itdetermines if the code memory is erased by testingthese memory regions. A ‘BLANK’ or ‘NOT BLANK’response is returned. If it is determined that the deviceis not blank, it must be erased before attempting toprogram the chip.

3.5 Code Memory Programming

3.5.1 PROGRAMMING METHODOLOGYCode memory (primary or auxiliary Flash) is pro-grammed with the PROGP command. PROGP programsone row of code memory starting from the memoryaddress specified in the command. The number ofPROGP commands required to program a devicedepends on the number of write blocks that must beprogrammed in the device.

A flowchart for programming code memory is shown inFigure 3-4. In this example, all 175,104 instructionwords of a dsPIC33E/PIC24E device are programmed.First, the number of commands to send (called‘RemainingCmds’ in the flowchart) is set to 1368 andthe destination address (called ‘BaseAddress’) is set to‘0’. Next, one write block in the device is programmedwith a PROGP command. Each PROGP commandcontains data for one row of code memory of thedsPIC33E/PIC24E. After the first command isprocessed successfully, ‘RemainingCmds’ isdecremented by ‘1’ and compared with ‘0’. Since thereare more PROGP commands to send, ‘BaseAddress’ isincremented by 0x100 to point to the next row ofmemory.

On the second PROGP command, the second row isprogrammed. This process is repeated until the entiredevice is programmed.

MCLR

PGEDx

PGECx

VDD

P6P14

b31 b30 b29 b28 b27 b2 b1 b0b3...

Program/Verify Entry Code = 0x4D434850

P1AP1B

P18

P19

0 1 0 0 1 0 0 0 0

P7VIH VIH

P21 P1 · 5

Note: If a bootloader needs to be programmed,the bootloader code must not beprogrammed into the first page of codememory. For example, if a bootloaderlocated at address 0x200 attempts toerase the first page, it would inadvertentlyerase itself. Instead, program thebootloader into the second page (e.g.,0x400).

© 2009-2011 Microchip Technology Inc. DS70619B-page 7

Page 8: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

FIGURE 3-4: FLOWCHART FOR PROGRAMMING CODE MEMORY

3.5.2 PROGRAMMING VERIFICATIONAfter code memory is programmed, the contents ofmemory can be verified to ensure that programmingwas successful. Verification requires code memory tobe read back and compared against the copy held inthe programmer’s buffer.

The READP command can be used to read back all theprogrammed code memory.

Alternatively, you can have the programmer performthe verification after the entire device is programmed,using a checksum computation.

BaseAddress = 0x0RemainingCmds = 1368

Start

FailureReport Error

End

Yes

No

RemainingCmds =RemainingCmds - 1

Yes

PASS?

No

BaseAddressCommand to Program

Send PROGP

RemainingCmdsIs

‘0’?

BaseAddress + 0x100BaseAddress =

PROGP responseIs

DS70619B-page 8 © 2009-2011 Microchip Technology Inc.

Page 9: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

4.0 CHECKSUM COMPUTATIONChecksums for devices are 16 bits in size. Thechecksum is calculated by summing the following:

• Contents of code memory locations• Contents of Configuration bytes

All memory locations are summed one byte at a timeusing only their native data size. Configuration bytesare summed by adding the lower byte of these loca-tions (the upper bytes are ignored), while code memoryis summed by adding all three bytes of code memory.

Table 4-1 is an example of the checksum calculation forthe dsPIC33EP64MC506 device.

Table 4-2 describes the Configuration bit masks foreach device.

TABLE 4-2: CONFIGURATION BIT MASKS

TABLE 4-1: CHECKSUM COMPUTATION EXAMPLE

Device Read CodeProtection Checksum Computation Erased

Value

Value with0xAAAAAA at 0x0

and LastCode Address

dsPIC33EP256MU806 Disabled CFGB(3) + SUM(0:0x02ABFF) + SUM(0x7FC000:0x7FFFFF)

0xA288 0x9E8C

Enabled CFGB(3) 0x04E2 0x04E2

Item Description:SUM(a:b) = Byte sum of locations a to b inclusive (all 3 bytes of code memory)CFGB = Configuration Block (masked) = Byte sum of ((FGS & 0x33(1)) + (FOSCSEL & 0x87) + (FOSC & 0xE7) + (FWDT & 0xFF) + (FPOR & 0x3F) + (FICD & 0xF7) + (FAS & 0x33(2)) + (FUID0 & 0xFF))Note 1: For FGS, the read mask is 0x33; however, because of the General Segment Key bits, 0x03 is used with code

protection disabled, and 0x30 is used with code protection enabled for the checksum calculations in Table 4-1.2: For FAS, the read mask is 0x33; however, because of the Auxiliary Segment Key bits, 0x03 is used with code

protection disabled, and 0x30 is used with code protection enabled for the checksum calculations in Table 4-1.3: For the checksum computation example the configuration bits are set to the recommended default value

shown in Table 6-6.

DeviceConfiguration Bit Masks

FGS FOSCSEL FOSC FWDT FPOR FICD FAS FUID0

dsPIC33EP256MU806 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFdsPIC33EP256MU810 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFdsPIC33EP256MU814 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFPIC24EP256GU810 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFPIC24EP256GU814 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFdsPIC33EP512MU810 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFdsPIC33EP512MU814 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFPIC24EP512GU810 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFPIC24EP512GU814 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFdsPIC33EP512MC806 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFdsPIC33EP512GP806 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFFPIC24EP512GP806 0x33 0x87 0xE7 0xFF 0x3F 0xF7 0x33 0xFF

© 2009-2011 Microchip Technology Inc. DS70619B-page 9

Page 10: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

4.1 Configuration Bits Programming

4.1.1 OVERVIEWThe dsPIC33E/PIC24E devices have Configurationbits stored in eight 8-bit Configuration registers,aligned on even configuration memory addressboundaries. These bits can be set or cleared to selectvarious device configurations. There are three types ofConfiguration bits: system operation bits, code-protectbits and unit ID bits. The system operation bitsdetermine the power-on settings for system level

components, such as oscillator and Watchdog Timer.The code-protect bits prevent program memory frombeing read and written.

The register descriptions for the FGS, FOSCSEL,FOSC, FWDT, FPOR, FAS and FICD Configurationregisters are shown in Table 4-3.

The Configuration register map is shown in Table 4-4.

Note 1: If any of the code-protect bits in FAS orFGS is clear, the entire device must beerased before it can be reprogrammed.

TABLE 4-3: dsPIC33E/PIC24E CONFIGURATION BITS DESCRIPTIONBit Field Register Description

GSSK<1:0> FGS General Segment Key bits.These bits must be set to ‘00’ if GWRP = 1 and GSS = 1.These bits must be set to ‘11’ for any other value of the GWRP and GSS bits.Any mismatch between either the GWRP or GSS bits, and the GSSK bits (as described above), will result in a locked device. A Flash bulk erase will be required to unlock the device.

GSS FGS General Segment Code-Protect bit1 = User program memory is not code-protected0 = User program memory is code-protected

GWRP FGS General Segment Write-Protect bit1 = User program memory is not write-protected0 = User program memory is write-protected

IESO FOSCSEL Two-speed Oscillator Start-up Enable bit1 = Start-up device with FRC, then automatically switch to the user-selected

oscillator source when ready0 = Start-up device with user-selected oscillator source

FNOSC<2:0> FOSCSEL Initial Oscillator Source Selection bits111 = Internal Fast RC (FRC) oscillator with postscaler110 = Internal Fast RC (FRC) oscillator with divide-by-16101 = LPRC oscillator100 = Secondary (LP) oscillator011 = Primary (XT, HS, EC) oscillator with PLL010 = Primary (XT, HS, EC) oscillator001 = Internal Fast RC (FRC) oscillator with PLL000 = FRC oscillator

FCKSM<1:0> FOSC Clock Switching Mode bits1x = Clock switching is disabled, Fail-Safe Clock Monitor is disabled01 = Clock switching is enabled, Fail-Safe Clock Monitor is disabled00 = Clock switching is enabled, Fail-Safe Clock Monitor is enabled

IOL1WAY FOSC Peripheral pin select configuration1 = Allow only one reconfiguration0 = Allow multiple reconfigurations

OSCIOFNC FOSC OSC2 Pin Function bit (except in XT and HS modes)1 = OSC2 is clock output0 = OSC2 is general purpose digital I/O pin

POSCMD<1:0> FOSC Primary Oscillator Mode Select bits11 = Primary oscillator disabled10 = HS Crystal Oscillator mode01 = XT Crystal Oscillator mode00 = EC (External Clock) mode

Note 1: This bit is not available on dsPIC33EP256MU806 (64-pin) devices.

DS70619B-page 10 © 2009-2011 Microchip Technology Inc.

Page 11: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

FWDTEN FWDT Watchdog Timer Enable bit1 = Watchdog Timer always enabled (LPRC oscillator cannot be disabled. Clearing the

SWDTEN bit in the RCON register has no effect.)0 = Watchdog Timer enabled/disabled by user software (LPRC can be disabled by

clearing the SWDTEN bit in the RCON register)WINDIS FWDT Watchdog Timer Window Enable bit

1 = Watchdog Timer in Non-Window mode0 = Watchdog Timer in Window mode

PLLKEN FWDT PLL Lock Wait Enable bit1 = Clock switches to the PLL source will wait until the PLL lock signal is valid0 = Clock switch will not wait for PLL lock

WDTPRE FWDT Watchdog Timer Prescaler bit1 = 1:1280 = 1:32

WDTPOST<3:0> FWDT Watchdog Timer Postscaler bits1111 = 1:32,7681110 = 1:16,384• ••0001 = 1:20000 = 1:1

APLK<1:0> FAS Auxiliary Segment Key bitsThese bits must be set to ‘00’ if AWRP = 1 and APL = 1.These bits must be set to ‘11’ for any other value of the AWRP and APL bits.Any mismatch between either the AWRP or APL bits, and the APLK bits (as described above), will result in a locked device. A Flash bulk erase will be required to unlock the device.

APL FAS Auxiliary Segment Code-protect bit1 = Auxiliary program memory is not code-protected0 = Auxiliary program memory is code-protected

AWRP FAS Auxiliary Segment Write-protect bit1 = Auxiliary program memory is not write-protected0 = Auxiliary program memory is write-protected

FPWRT<2:0> FPOR Power-on Reset Timer Value Select bits111 = PWRT = 128 ms110 = PWRT = 64 ms101 = PWRT = 32 ms100 = PWRT = 16 ms011 = PWRT = 8 ms010 = PWRT = 4 ms001 = PWRT = 2 ms000 = PWRT = Disabled

BOREN FPOR Brown-out Reset (BOR) Detection Enable bit1 = BOR is enabled0 = BOR is disabled

ALTI2C2(1) FPOR Alternate I2C™ pins for I2C21 = I2C2 mapped to SDA2/SCL2 pins0 = I2C2 mapped to ASDA2/ASCL2 pins

ALTI2C1 FPOR Alternate I2C pins for I2C11 = I2C1 mapped to SDA1/SCL1 pins0 = I2C1 mapped to ASDA1/ASCL1 pins

TABLE 4-3: dsPIC33E/PIC24E CONFIGURATION BITS DESCRIPTION (CONTINUED)Bit Field Register Description

Note 1: This bit is not available on dsPIC33EP256MU806 (64-pin) devices.

© 2009-2011 Microchip Technology Inc. DS70619B-page 11

Page 12: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

TABLE 4-4: dsPIC33E/PIC24E DEVICE CONFIGURATION REGISTER MAP

JTAGEN FICD JTAG Enable bit1 = JTAG enabled0 = JTAG disabled

RSTPRI FICD Reset Target Vector Select bit1 = Device will execute code from primary Flash memory on a reset0 = Device will execute code from auxiliary Flash memory on a reset

ICS<1:0> FICD ICD Communication Channel Select bits11 = Communicate on PGEC1 and PGED110 = Communicate on PGEC2 and PGED201 = Communicate on PGEC3 and PGED300 = Reserved, do not use

TABLE 4-3: dsPIC33E/PIC24E CONFIGURATION BITS DESCRIPTION (CONTINUED)Bit Field Register Description

Note 1: This bit is not available on dsPIC33EP256MU806 (64-pin) devices.

Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

0xF80000 Reserved — — — — — — — —0xF80002 Reserved — — — — — — — —0xF80004 FGS — — GSSK<1:0> — — GSS GWRP0xF80006 FOSCSEL IESO — — — FNOSC<2:0>0xF80008 FOSC FCKSM<1:0> IOL1WAY — — OSCIOFNC POSCMD<1:0>0xF8000A FWDT FWDTEN WINDIS PLLKEN WDTPRE WDTPOST<3:0>0xF8000C FPOR — — ALTI2C2(2) ALTI2C1 BOREN FPWRT<2:0>0xF8000E FICD Reserved(1) JTAGEN Reserved(1) — RSTPRI ICS<1:0>0xF80010 FAS — — APLK<1:0> — — APL AWRP0xF80012 FUID0 User Unit ID Byte 0Legend: — = unimplemented bit, read as ‘0’Note 1: These bits are reserved for use by development tools and must be programmed as ‘1’.

2: These bits are reserved on dsPIC33EP256MU806 (64-pin) devices and always read as ‘1’.

DS70619B-page 12 © 2009-2011 Microchip Technology Inc.

Page 13: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

4.1.2 PROGRAMMING METHODOLOGYConfiguration bits may be programmed a single byte ata time using the PROGC command. This commandspecifies the configuration data and Configurationregister address.

Eight PROGC commands are required to program all theConfiguration bits. A flowchart for Configuration bit pro-gramming is shown in Figure 4-1.

4.1.3 PROGRAMMING VERIFICATIONAfter the Configuration bits are programmed, thecontents of memory should be verified to ensure thatthe programming was successful. Verification requiresthe Configuration bits to be read back and comparedagainst the copy held in the programmer’s buffer. TheREADC command reads back the programmedConfiguration bits and verifies that the programmingwas successful.

Any unimplemented Configuration bits are read-onlyand read as ‘0’. The reserved bits are read-only andread as ‘1’.

FIGURE 4-1: CONFIGURATION BIT PROGRAMMING FLOW

Note: If the General Code SegmentCode-Protect bit (GSS) is programmedto ‘0’, code memory is code-protectedand cannot be read. Code memory mustbe verified before enabling readprotection. See Section 4.1.4“CodeGuard™ Security ConfigurationBits” for detailed information aboutcode-protect Configuration bits.

Send PROGCCommand

ConfigAddress = 0xF80004

IsPROGC response

PASS?

No

Yes

No

FailureReport Error

Start

End

Yes

IsConfigAddress

0xF80012?

ConfigAddress =ConfigAddress + 2

© 2009-2011 Microchip Technology Inc. DS70619B-page 13

Page 14: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

4.1.4 CodeGuard™ SECURITY CONFIGURATION BITS

The FGS and FAS Configuration registers are specialConfiguration registers that control the level of codeprotection for the General Segment (user code mem-ory) and auxiliary Flash memory, respectively. For eachof these memory regions, two main forms of code pro-tection are provided. One form prevents code memoryfrom being written (write protection), while the otherprevents code memory from being read (readprotection).

The GWRP and AWRP bits control write protection andthe GSS and APL bits control read protection. The ChipErase ERASEB command sets these four codeprotection bits to ‘1’, which allows the device to beprogrammed.

When write protection is enabled, any programmingoperation to code memory will fail. When readprotection is enabled, any read from code memory willcause a ‘0x0’ to be read, regardless of the actualcontents of code memory. Since the programmingexecutive always verifies what it programs, attemptingto program code memory with read protection enabledwill also result in failure.

It is imperative that all of the previously described codeprotection bits are ‘1’ while the device is being pro-grammed and verified. Only after the device is pro-grammed and verified should any of the above bits beprogrammed to ‘0’.

4.1.5 BENEFIT OF USER UNIT IDThe dsPIC33E/PIC24E devices provide an 8-bitConfiguration register (FUID0) for the user to storeproduct-specific information, such as unit serialnumbers and other product manufacturing data.

4.2 Exiting Enhanced ICSP ModeExiting Program/Verify mode is done by removing VIHfrom MCLR, as shown in Figure 4-2. The onlyrequirement for exit is that an interval P16 shouldelapse between the last clock and program signals onPGC and PGD before removing VIH.

FIGURE 4-2: EXITING ENHANCED ICSP™ MODE

Note: All code-protect/write-protect bits in theFAS and FGS Configuration registers canonly be programmed to a value of ‘0’. theERASEB command is the only way toreprogram code-protect bits from ON (‘0’)to OFF (‘1’).

MCLR

P16

PGD

PGD = Input

PGC

VDD

VIH

VIH

P17

DS70619B-page 14 © 2009-2011 Microchip Technology Inc.

Page 15: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

5.0 THE PROGRAMMING EXECUTIVE

5.1 Programming Executive Communication

The programmer and programming executive have amaster-slave relationship, where the programmer isthe master programming device and the programmingexecutive is the slave.

All communication is initiated by the programmer in theform of a command. Only one command at a time canbe sent to the programming executive. In turn, theprogramming executive only sends one response tothe programmer after receiving and processing acommand. The programming executive command setis described in Section 5.2 “Programming ExecutiveCommands”. The response set is described inSection 5.3 “Programming Executive Responses”.

5.1.1 COMMUNICATION INTERFACE AND PROTOCOL

The ICSP/Enhanced ICSP interface is a 2-wire SPIimplemented using the PGC and PGD pins. The PGCpin is used as a clock input pin and the clock sourcemust be provided by the programmer. The PGD pin isused for sending command data to and receivingresponse data from the programming executive.

FIGURE 5-1: PROGRAMMING EXECUTIVE SERIAL TIMING

Since a 2-wire SPI is used, and data transmissions arebidirectional, a simple protocol is used to control thedirection of PGD. When the programmer completes acommand transmission, it releases the PGD line andallows the programming executive to drive this linehigh. The programming executive keeps the PGD linehigh to indicate that it is processing the command.

After the programming executive has processed thecommand, it brings PGD low (P9b) to indicate to theprogrammer that the response is available to beclocked out. The programmer can begin to clock outthe response after maximum wait (P9b) and it mustprovide the necessary amount of clock pulses toreceive the entire response from the programmingexecutive.

After the entire response is clocked out, theprogrammer should terminate the clock on PGC until itis time to send another command to the programmingexecutive. This protocol is shown in Figure 5-2.

5.1.2 SPI RATEIn Enhanced ICSP mode, the dsPIC33E/PIC24E familydevices operate from the Fast Internal RC oscillator,which has a nominal frequency of 7.3728 MHz. Thisoscillator frequency yields an effective system clockfrequency of 3.6864 MHz. To ensure that theprogrammer does not clock too fast, it is recommendedthat a 1.8432 MHz clock be provided by theprogrammer.

5.1.3 TIME OUTSThe programming executive uses no Watchdog or timeout for transmitting responses to the programmer. If theprogrammer does not follow the flow controlmechanism using PGC as described in Section 5.1.1“Communication Interface and Protocol”, it ispossible that the programming executive will behaveunexpectedly while trying to send a response to theprogrammer. Since the programming executive has notime out, it is imperative that the programmer correctlyfollow the described communication protocol.

As a safety measure, the programmer should use thecommand time outs identified in Table 5-1. If thecommand time out expires, the programmer shouldreset the programming executive and startprogramming the device again.

Note: The Programming Executive (PE) can belocated within the following folder within yourinstallation of MPLAB® IDE:...\Microchip\MPLAB IDE\REAL ICE,and then selecting the hex PE file,RIPE_10_xxxxxx.hex (where xxxxxx isthe version number).

Note: For Enhanced ICSP, all serial data istransmitted on the falling edge of PGCand latched on the rising edge of PGC. Alldata transmissions are sent to the MostSignificant bit first using 16-bit mode (seeFigure 5-1).

PGC

PGD

1 2 3 11 13 15 161412

LSb14 13 12 11

4 5 6

MSb 123... 45

P2

P3

P1

P1BP1A

© 2009-2011 Microchip Technology Inc. DS70619B-page 15

Page 16: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

FIGURE 5-2: PROGRAMMING EXECUTIVE – PROGRAMMER COMMUNICATION PROTOCOL

5.2 Programming Executive Commands

The programming executive command set is shown inTable 5-1. This table contains the opcode, mnemonic,length, time out and description for each command.Functional details on each command are provided inthe command descriptions (Section 5.2.4 “CommandDescriptions”).

5.2.1 COMMAND FORMATAll programming executive commands have a generalformat consisting of a 16-bit header and any requireddata for the command (see Figure 5-3). The 16-bitheader consists of a 4-bit opcode field, which is used toidentify the command, followed by a 12-bit commandlength field.

FIGURE 5-3: COMMAND FORMAT

The command opcode must match one of those in thecommand set. Any command that is received whichdoes not match the list in Table 5-1 will return a “NACK”response (see Section 5.3.1.1 “Opcode Field”).

The command length is represented in 16-bit wordssince the SPI operates in 16-bit mode. Theprogramming executive uses the command length fieldto determine the number of words to read from the SPIport. If the value of this field is incorrect, the commandwill not be properly received by the programmingexecutive.

5.2.2 PACKED DATA FORMATWhen 24-bit instruction words are transferred acrossthe 16-bit SPI interface, they are packed to conservespace using the format shown in Figure 5-4. Thisformat minimizes traffic over the SPI and provides theprogramming executive with data that is properlyaligned for performing table write operations.

FIGURE 5-4: PACKED INSTRUCTION WORD FORMAT

5.2.3 PROGRAMMING EXECUTIVE ERROR HANDLING

The programming executive will “NACK” allunsupported commands. Additionally, due to thememory constraints of the programming executive, nochecking is performed on the data contained in theprogrammer command. It is the responsibility of theprogrammer to command the programming executivewith valid command arguments or the programmingoperation may fail. Additional information on errorhandling is provided in Section 5.3.1.3 “QE_CodeField”.

1 2 15 16 1 2 15 16

PGC

PGD

PGC = Input PGC = Input (Idle)

Host TransmitsLast Command Word

PGD = Input PGD = Output

P8

1 2 15 16

MSB X X X LSB MSB X X X LSB MSB X X X LSB1 0

P9b

PGC = InputPGD = Output

P9a

Programming ExecutiveProcesses Command Host Clocks Out Response

15 12 11 0Opcode Length

Command Data First Word (if required)••

Command Data Last Word (if required)

Note: When the number of instruction wordstransferred is odd, MSB2 is zero andLSW2 can not be transmitted.

15 8 7 0LSW1

MSB2 MSB1LSW2

LSWx: Least Significant 16 bits of instruction wordMSBx: Most Significant Byte of instruction word

DS70619B-page 16 © 2009-2011 Microchip Technology Inc.

Page 17: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

TABLE 5-1: PROGRAMMING EXECUTIVE COMMAND SET

5.2.4 COMMAND DESCRIPTIONSAll commands supported by the programming executiveare described in Section 5.2.5 “SCHECK Command”through Section 5.2.16 “QVER Command”.

5.2.5 SCHECK COMMAND

The SCHECK command instructs the programmingexecutive to do nothing but generate a response. Thiscommand is used as a “Sanity Check” to verify that theprogramming executive is operational.

Expected Response (2 words):0x10000x0002

Opcode Mnemonic Length(16-bit words) Time Out Description

0x0 SCHECK 1 1 ms Sanity check.0x1 READC 3 1 ms Read an 8-bit word from the specified Configuration register

or Device ID register.0x2 READP 4 1 ms/row Read ‘N’ 24-bit instruction words of primary or auxiliary

Flash memory starting from the specified address.0x3 Reserved N/A N/A This command is reserved. It will return a NACK.0x4 PROGC 4 5 ms Write an 8-bit word to the specified Configuration register.0x5 PROGP 195 5 ms Program one row of primary or auxiliary Flash memory at

the specified address, then verify. 0x6 ERASEBP 1 75 ms Erase entire primary Flash memory and FGS register.0x7 ERASEB 1 125 ms Bulk Erase the device.0x8 ERASEBA 1 75 ms Erase entire auxiliary Flash memory and FAS register.0x9 ERASEP 3 25 ms Command to erase a page.0xA Reserved N/A N/A This command is reserved. It will return a NACK.0xB QVER 1 1 ms Query the programming executive software version.0xC CRCP 5 1s Performs a CRC-16 on the specified range of memory.0xD Reserved N/A N/A This command is reserved. It will return a NACK.0xE QBLANK 5 700 ms Query to check whether the code memory is blank.

Note: One row of code memory consists of (64) 24-bit words. Refer to Table 2-2 for device-specific information.

15 12 11 0Opcode Length

Field Description

Opcode 0x0Length 0x1

Note: This instruction is not required forprogramming, but is provided fordevelopment purposes only.

© 2009-2011 Microchip Technology Inc. DS70619B-page 17

Page 18: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

5.2.6 READC COMMAND

The READC command instructs the programmingexecutive to read N Configuration registers or DeviceID registers, starting from the 24-bit address specifiedby Addr_MSB and Addr_LS. This command can onlybe used to read 8-bit or 16-bit data.

When this command is used to read Configurationregisters, the upper byte in every data word returned bythe programming executive is 0x00 and the lower bytecontains the Configuration register value.

Expected Response (4 + 3 * (N - 1)/2 words for N odd):0x11002 + NConfiguration register or Device ID Register 1... Configuration register or Device ID Register N

5.2.7 READP COMMAND

The READP command instructs the programmingexecutive to read N 24-bit words of code memory,starting from the 24-bit address specified by Addr_MSBand Addr_LS. This command can only be used to read24-bit data. All data returned in the response to thiscommand uses the packed data format described inSection 5.2.2 “Packed Data Format”.

Expected Response (2 + 3 * N/2 words for N even):0x12002 + 3 * N/2Least significant program memory word 1... Least significant data word N

Expected Response (4 + 3 * (N - 1)/2 words for N odd):0x12004 + 3 * (N - 1)/2Least significant program memory word 1... MSB of program memory word N (zero padded)

15 12 11 8 7 0Opcode Length

N Addr_MSBAddr_LS

Field Description

Opcode 0x1Length 0x3N Number of 8-bit Configuration registers

or Device ID registers to read (maximum of 256).

Addr_MSB MSB of 24-bit source address.Addr_LS Least Significant 16 bits of 24-bit

source address.

Note: Reading unimplemented memory willcause the programming executive toreset. Please ensure that only memorylocations present on a particular deviceare accessed.

15 12 11 8 7 0Opcode Length

NReserved Addr_MSB

Addr_LS

Field Description

Opcode 0x2Length 0x4N Number of 24-bit instructions to read

(maximum of 32768).Reserved 0x0Addr_MSB MSB of 24-bit source address.Addr_LS Least Significant 16 bits of 24-bit

source address.

Note: Reading unimplemented memory willcause the programming executive toreset. Please ensure that only memorylocations present on a particular deviceare accessed.

DS70619B-page 18 © 2009-2011 Microchip Technology Inc.

Page 19: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

5.2.8 PROGC COMMAND

The PROGC command instructs the programmingexecutive to program a single Configuration register,located at the specified memory address.

After the specified data word has been programmed tocode memory, the programming executive verifies theprogrammed data against the data in the command.

Expected Response (2 words):0x14000x0002

5.2.9 PROGP COMMAND

The PROGP command instructs the programmingexecutive to program one row of code memory(128 instruction words) to the specified memoryaddress. Programming begins with the row addressspecified in the command. The destination addressshould be a multiple of 0x100.

The data to program the memory, located in commandwords D_1 through D_192, must be arranged using thepacked instruction word format shown in Figure 5-4.

After all data has been programmed to code memory,the programming executive verifies the programmeddata against the data in the command.

Expected Response (2 words):0x15000x0002

15 12 11 8 7 0Opcode Length

Reserved Addr_MSBAddr_LS

Data

Field Description

Opcode 0x4Length 0x4Reserved 0x0Addr_MSB MSB of 24-bit destination address.Addr_LS Least Significant 16 bits of 24-bit

destination address.Data 8-bit data word.

15 12 11 8 7 0Opcode Length

Reserved Addr_MSBAddr_LS

D_1D_2...

D_N

Field Description

Opcode 0x5Length 0x63Reserved 0x0Addr_MSB MSB of 24-bit destination address.Addr_LS Least Significant 16 bits of 24-bit

destination address.D_1 16-bit data word 1.D_2 16-bit data word 2.... 16-bit data word 3 through 191.D_192 16-bit data word 192.

Note: Refer to Table 2-2 for code memory sizeinformation.

© 2009-2011 Microchip Technology Inc. DS70619B-page 19

Page 20: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

5.2.10 ERASEB COMMAND

The ERASEB command instructs the programmingexecutive to perform a Bulk Erase (i.e., erase all of theprimary Flash memory, auxiliary Flash memory,executive memory and code-protect bits).

Expected Response (2 words):0x1700

0x0002

5.2.11 ERASEBP COMMAND

The ERASEBP command instructs the programmingexecutive to perform a Bulk Erase (i.e., erase all of theprimary Flash memory and the FGS register).

Expected Response (2 words):0x1600

0x0002

5.2.12 ERASEBA COMMAND

The ERASEBA command instructs the programmingexecutive to perform a Bulk Erase (i.e., erase all of theauxiliary Flash memory and the FAS register).

Expected Response (2 words):0x1800

0x0002

5.2.13 ERASEP COMMAND

The ERASEP command instructs the programmingexecutive to page erase [NUM_PAGES] of code mem-ory. The code memory must be erased at an “even”1024 instruction word address boundary

Expected Response (2 words):0x19000x0002

15 12 11 0Opcode Length

Field Description

Opcode 0x7Length 0x1

15 12 11 0Opcode Length

Field Description

Opcode 0x6Length 0x1

15 12 11 0Opcode Length

Field Description

Opcode 0x8Length 0x1

15 12 11 8 7 0

Opcode Length

NUM_PAGES Addr_MSB

Addr_LS

Field Description

Opcode 0x9Length 0x3NUM_PAGES Up to 255Addr_MSB Most Significant Byte of the 24-bit

addressAddr_LS Least Significant 16-bits of the 24-bit

address

DS70619B-page 20 © 2009-2011 Microchip Technology Inc.

Page 21: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

5.2.14 CRCP COMMAND

The CRCP command performs a CRC-16 on the rangeof memory specified. This command can substitute fora full chip verify. Data is shifted in a packed method asdemonstrated in Figure 5-4, byte-wise LeastSignificant Byte (LSB) first.

Example:CRC-CCITT-16 with test data of “123456789” becomes0x29B1

Expected Response (3 words):QE_Code: 0x1C00

Length: 0x0003

CRC Value: 0xXXXX

5.2.15 QBLANK COMMAND

The QBLANK command queries the programmingexecutive to determine if the contents of code memoryare blank (contains all ‘1’s). The size of code memoryto check must be specified in the command.

The Blank Check for code memory begins at [Addr] andadvances toward larger addresses for the specifiednumber of instruction words.

QBLANK returns a QE_Code of 0xF0 if the specifiedcode memory is blank; otherwise, QBLANK returns aQE_Code of 0x0F.

Expected Response (2 words for blank device):0x1DF00x0002

Expected Response (2 words for non-blank device):0x1D0F0x0002

15 12 11 8 7 0

Opcode Length

Reserved Addr_MSB

Addr_LSW

Reserved Size_MSB

Size_LSW

Field Description

Opcode 0xCLength 0x5Addr_MSB Most Significant Byte of 24-bit

addressAddr_LSW Least Significant 16-bits of 24-bit

addressSize Number of 24-bit locations (address

range divided by 2)

15 12 11 0Opcode Length

Reserved Size_MSBSize_LSW

Reserved Addr_MSBAddr_LSW

Field Description

Opcode 0xELength 0x5Size Length of program memory to check

(in 24-bit words) + Addr_MSAddr_MSB Most Significant Byte of the 24-bit

addressAddr_LSW Least Significant 16-bits of the 24-bit

address

Note: The QBLANK command does not checkthe system operation Configuration bitssince these bits are not set to ‘1’ when aChip Erase is performed.

© 2009-2011 Microchip Technology Inc. DS70619B-page 21

Page 22: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

5.2.16 QVER COMMAND

The QVER command queries the version of theprogramming executive software stored in testmemory. The “version.revision” information is returnedin the response’s QE_Code using a single byte with thefollowing format: main version in upper nibble andrevision in the lower nibble (i.e., 0x23 meansversion 2.3 of programming executive software).

Expected Response (2 words):0x1BMN (where “MN” stands for version M.N)0x0002

5.3 Programming Executive Responses

The programming executive sends a response to theprogrammer for each command that it receives. Theresponse indicates if the command was processedcorrectly. It includes any required response data orerror data.

The programming executive response set is shown inTable 5-2. This table contains the opcode, mnemonicand description for each response. The response formatis described in Section 5.3.1 “Response Format”.

TABLE 5-2: PROGRAMMING EXECUTIVE RESPONSE OPCODES

5.3.1 RESPONSE FORMATAll programming executive responses have a generalformat consisting of a two-word header and anyrequired data for the command.

5.3.1.1 Opcode FieldThe opcode is a 4-bit field in the first word of theresponse. The opcode indicates how the commandwas processed (see Table 5-2). If the command wasprocessed successfully, the response opcode is PASS.If there was an error in processing the command, theresponse opcode is FAIL and the QE_Code indicatesthe reason for the failure. If the command sent tothe programming executive is not identified, theprogramming executive returns a NACK response.

5.3.1.2 Last_Cmd FieldThe Last_Cmd is a 4-bit field in the first word ofthe response and indicates the command that theprogramming executive processed. Since theprogramming executive can only process onecommand at a time, this field is technically not required.However, it can be used to verify that the programmingexecutive correctly received the command that theprogrammer transmitted.

15 12 11 0Opcode Length

Field Description

Opcode 0xBLength 0x1

Opcode Mnemonic Description

0x1 PASS Command successfully processed.

0x2 FAIL Command unsuccessfully processed.

0x3 NACK Command not known.

Field Description

Opcode Response opcode.Last_Cmd Programmer command that

generated the response.QE_Code Query code or error code.Length Response length in 16-bit words

(includes 2 header words).D_1 First 16-bit data word (if applicable).D_N Last 16-bit data word (if applicable).

15 12 11 8 7 0

Opcode Last_Cmd QE_Code

Length

D_1 (if applicable)

...

D_N (if applicable)

DS70619B-page 22 © 2009-2011 Microchip Technology Inc.

Page 23: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

5.3.1.3 QE_Code FieldThe QE_Code is a byte in the first word of theresponse. This byte is used to return data for querycommands and error codes for all other commands.

When the programming executive processes one of thetwo query commands (QBLANK or QVER), the returnedopcode is always PASS and the QE_Code holds thequery response data. The format of the QE_Code forboth queries is shown in Table 5-3.

TABLE 5-3: QE_Code FOR QUERIES

When the programming executive processes anycommand other than a Query, the QE_Coderepresents an error code. Supported error codes areshown in Table 5-4. If a command is successfullyprocessed, the returned QE_Code is set to 0x0, whichindicates that there is no error in the commandprocessing. If the verify of the programming for thePROGP or PROGC command fails, the QE_Code is set to0x1. For all other programming executive errors, theQE_Code is 0x2.

TABLE 5-4: QE_Code FOR NON-QUERY COMMANDS

5.3.1.4 Response LengthThe response length indicates the length of theprogramming executive’s response in 16-bit words.This field includes the 2 words of the response header.

With the exception of the response for the READP command, the length of each response is only 2 words.

The response to the READP command uses the packedinstruction word format described in Section 5.2.2“Packed Data Format”. When reading an odd num-ber of program memory words (N odd), the responseto the READP command is (3 * (N + 1)/2 + 2) words.When reading an even number of program memorywords (N even), the response to the READP commandis (3 * N/2 + 2) words.

Query QE_Code

QBLANK 0x0F = Code memory is NOT blank0xF0 = Code memory is blank

QVER 0xMN, where programming executive software version = M.N(i.e., 0x32 means software version 3.2).

QE_Code Description

0x0 No error. 0x1 Verify failed.0x2 Other error.

© 2009-2011 Microchip Technology Inc. DS70619B-page 23

Page 24: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.0 DEVICE PROGRAMMING – ICSPICSP mode is a special programming protocol thatallows you to read and write to dsPIC33E/PIC24Edevice family memory. The ICSP mode is the mostdirect method used to program the device; however,note that Enhanced ICSP is faster. ICSP mode alsohas the ability to read the contents of executivememory to determine if the programming executive ispresent. This capability is accomplished by applyingcontrol codes and instructions serially to the deviceusing pins PGC and PGD.

In ICSP mode, the system clock is taken from the PGCpin, regardless of the device’s oscillator Configurationbits. All instructions are shifted serially into an internalbuffer, then loaded into the instruction register andexecuted. No program fetching occurs from internalmemory. Instructions are fed in 24 bits at a time. PGDis used to shift data in, and PGC is used as both theserial shift clock and the CPU execution clock.

6.1 Overview of the Programming Process

Figure 6-1 shows the high-level overview of theprogramming process. After entering ICSP mode, thefirst action is to Bulk Erase the device. Next, the codememory is programmed, followed by the deviceConfiguration registers. Code memory (including theConfiguration registers) is then verified to ensure thatprogramming was successful. Then, program thecode-protect Configuration bits, if required.

FIGURE 6-1: HIGH-LEVEL ICSP™ PROGRAMMING FLOW

Note: During ICSP operation, the operatingfrequency of PGC must not exceed5 MHz.

Start

Perform BulkErase

Program Memory

Verify Program

End

Enter ICSP™

Program Configuration Bits

Verify Configuration Bits

Exit ICSP

DS70619B-page 24 © 2009-2011 Microchip Technology Inc.

Page 25: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.2 Entering ICSP ModeAs shown in Figure 6-5, entering ICSP Program/Verifymode requires three steps:1. MCLR is briefly driven high then low (P21)(1).2. A 32-bit key sequence is clocked into PGD.3. MCLR is then driven high within a specified

period of time and held.

The programming voltage applied to MCLR is VIH,which is essentially VDD in the case of dsPIC33E/PIC24E devices. There is no minimum time require-ment for holding at VIH. After VIH is removed, an intervalof at least P18 must elapse before presenting the keysequence on PGD.The key sequence is a specific 32-bit pattern,‘0100 1101 0100 0011 0100 1000 0101 0001’(more easily remembered as 0x4D434851 inhexadecimal). The device will enter Program/Verifymode only if the sequence is valid. The Most Significantbit of the most significant nibble must be shifted in first. Once the key sequence is complete, VIH must beapplied to MCLR and held at that level for as long asProgram/Verify mode is to be maintained. An interval ofat least time P19, P7, and P1*5 must elapse before pre-senting data on PGD. Signals appearing on PGDbefore this time has elapsed will not be interpreted asvalid.On successful entry, the program memory can beaccessed and programmed in serial fashion. While inICSP mode, all unused I/Os are placed in thehigh-impedance state.

6.3 ICSP OperationAfter entering into ICSP mode, the CPU is Idle.Execution of the CPU is governed by an internal statemachine. A 4-bit control code is clocked in using PGCand PGD and this control code is used to command theCPU (see Table 6-1).

The SIX control code is used to send instructions to theCPU for execution and the REGOUT control code isused to read data out of the device via the VISI register.

TABLE 6-1: CPU CONTROL CODES IN ICSP™ MODE

6.3.1 SIX SERIAL INSTRUCTION EXECUTION

The SIX control code allows execution of dsPIC33E/PIC24E Programming Specification assembly instruc-tions. When the SIX code is received, the CPU is sus-pended for 24 clock cycles, as the instruction is thenclocked into the internal buffer. Once the instruction isshifted in, the state machine allows it to be executed overthe next four clock cycles. While the received instructionis executed, the state machine simultaneously shifts inthe next 4-bit command (see Figure 6-3).

6.3.2 REGOUT SERIAL INSTRUCTION EXECUTION

The REGOUT control code allows for data to beextracted from the device in ICSP mode. It is used toclock the contents of the VISI register out of the deviceover the PGD pin. After the REGOUT control code isreceived, the CPU is held Idle for eight cycles. After theseeight cycles, an additional 16 cycles are required to clockthe data out (see Figure 6-4).

The REGOUT code is unique because the PGD pin isan input when the control code is transmitted to thedevice. However, after the control code is processed,the PGD pin becomes an output as the VISI register isshifted out.

Note 1: The MCLR capacitor value can vary thehigh time required for entering ICSPmode.

4-Bit Control Code Mnemonic Description

0000b SIX Shift in 24-bit instruction and execute.

0001b REGOUT Shift out the VISIregister.

0010b-1111b N/A Reserved.

Note 1: Coming out of the ICSP entry sequence,the first 4-bit control code is alwaysforced to SIX and a forced NOP instructionis executed by the CPU. Five additionalPGC clocks are needed on start-up,thereby resulting in a 9-bit SIX commandinstead of the normal 4-bit SIX command.After the forced SIX is clocked in, ICSPoperation resumes as normal (the next24 clock cycles load the first instructionword to the CPU). See Figure 6-2 fordetails.

2: TBLRDH and TBLRDL instructions mustbe followed by five NOP instructions.TBLWTH and TBLWTL instructions mustbe followed by two NOP instructions.

Note: The device will latch input PGD data onthe rising edge of PGC and will outputdata on the PGD line on the rising edge ofPGC. For all data transmissions, the LeastSignificant bit (LSb) is transmitted first.

© 2009-2011 Microchip Technology Inc. DS70619B-page 25

Page 26: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

FIGURE 6-2: PROGRAM ENTRY AFTER RESET

FIGURE 6-3: SIX SERIAL EXECUTION

FIGURE 6-4: REGOUT SERIAL EXECUTION

P4

2 3 1 2 3 23 24 1 2 3 4P1

PGCP4a

PGD

24-Bit Instruction Fetch Execute 24-Bit Instruction,Execute PC - 1,

1 4

0 0 0 0

Fetch SIX Control Code Fetch Next Control Code

4 5 6 7 8 18 19 20 21 2217

LSB X X X X X X X X X X X X X X MSB

PGD = Input

P2

P3P1B

P1A

5 6 7

0 0 0 00 0 0

8 9

0 0

P4

1 2 3 23 24 1 2 3 4P1

PGCP4a

PGD

24-Bit Instruction Fetch Execute 24-Bit Instruction,Execute PC - 1,Fetch SIX Control Code Fetch Next Control Code

4 5 6 7 8 18 19 20 21 2217

LSB X X X X X X X X X X X X X X MSB

PGD = Input

P2

P3P1B

P1A

1 2

0 0 0 00 0

3 4

0 0

1 2 3 4 1 2 7 8PGC

P4

PGD

PGD = Input

Execute Previous Instruction, CPU Held in Idle Shift Out VISI Register<15:0>

P5

PGD = Output

1 2 3 1 2 3 4

P4a

11 13 15 161412

No Execution Takes Place,Fetch Next Control Code

0 0 0 0 0

PGD = Input

MSb1 2 3 41

4 5 6

LSb 141312... 11100

Fetch REGOUT Control Code

0

DS70619B-page 26 © 2009-2011 Microchip Technology Inc.

Page 27: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.4 Flash Memory Programming in ICSP Mode

6.4.1 PROGRAMMING OPERATIONSFlash memory write and erase operations arecontrolled by the NVMCON register. Programming isperformed by setting NVMCON to select the type oferase operation (Table 6-2) or write operation(Table 6-3) and initiating the programming by settingthe WR control bit (NVMCON<15>). In ICSP mode, all programming operations areself-timed. There is an internal delay between the usersetting the WR control bit and the automatic clearing ofthe WR control bit when the programming operation iscomplete. Please refer to Section 9.0 “AC/DCCharacteristics and Timing Requirements” fordetailed information about the delays associated withvarious programming operations.

TABLE 6-2: NVMCON ERASE OPERATIONS

TABLE 6-3: NVMCON WRITE OPERATIONS

6.4.2 STARTING AND STOPPING A PROGRAMMING CYCLE

The WR bit (NVMCON<15>) is used to start an eraseor write cycle. Setting the WR bit initiates theprogramming cycle.All erase and write cycles are self-timed. The WR bitshould be polled to determine if the erase or write cyclehas been completed. Starting a programming cycle isperformed as follows:

BSET NVMCON, #WR

FIGURE 6-5: ENTERING ICSP™ MODE

NVMCONValue Erase Operation

0x400F Erase all primary and auxiliary program Flash memory, executive memory and CodeGuard™ Configuration registers (does not erase Unit ID or Device ID registers).

0x400E Erase all primary and auxiliary user program Flash memory and CodeGuard Configuration registers (does not erase Unit ID or Device ID registers).

0x400D Erase entire primary program Flash memory and FGS Configuration register.

0x400A Erase entire auxiliary program Flash memory and FAS Configuration register.

0x4003 Erase a page of code memory or executive memory.

NVMCONValue Write Operation

0x4002 Program 1 row (128 instruction words) of primary or auxiliary Flash memory or executive memory.

0x4001 Program an even-odd pair of words in primary or auxiliary Flash memory.

0x4000 Write a Configuration register byte.

MCLR

PGEDx

PGECx

VDD

P6P14

b31 b30 b29 b28 b27 b2 b1 b0b3...

Program/Verify Entry Code = 0x4D434851

P1AP1B

P18

P19

0 1 0 0 1 0 0 0 1

P7VIH VIH

P21 P1 · 5

© 2009-2011 Microchip Technology Inc. DS70619B-page 27

Page 28: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

REGISTER 6-1: NVMCON: NON-VOLATILE MEMORY (NVM) CONTROL REGISTER

R/SO-0(1) R/W-0(1) R/W-0(1) R/W-0 U-0 U-0 U-0 U-0WR WREN WRERR NVMSIDL(2) — — — —

bit 15 bit 8

U-0 U-0 U-0 U-0 R/W-0(1) R/W-0(1) R/W-0(1) R/W-0(1)

— — — — NVMOP<3:0>(3,5)

bit 7 bit 0

Legend: SO = Satiable only bitR = 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

bit 15 WR: Write Control bit1 = Initiates a Flash memory program or erase operation. The operation is self-timed and the bit is

cleared by hardware once operation is complete0 = Program or erase operation is complete and inactive

bit 14 WREN: Write Enable bit1 = Enable Flash program/erase operations0 = Inhibit Flash program/erase operations

bit 13 WRERR: Write Sequence Error Flag bit1 = An improper program or erase sequence attempt or termination has occurred (bit is set

automatically on any set attempt of the WR bit)0 = The program or erase operation completed normally

bit 12 NVMSIDL: NVM Stop-in-Idle Control bit(2)

1 = Discontinue primary and auxiliary Flash operation when the device enters Idle mode0 = Continue primary and auxiliary Flash operation when the device enters Idle mode

bit 11-4 Unimplemented: Read as ‘0’bit 3-0 NVMOP<3:0>: NVM Operation Select bits(3,5)

1111 = User memory (primary and auxiliary Flash) and executive memory bulk erase operation 1110 = User memory bulk erase operation (primary and auxiliary Flash)1101 = Bulk erase primary program Flash memory1100 = Reserved1011 = Reserved1010 = Bulk erase auxiliary program Flash memory0011 = Memory page erase operation0010 = Memory row program operation0001 = Memory double-word (even-odd pair of words aligned at an address that is a multiple of 0x4)

program operation0000 = Program a single configuration register byte

Note 1: These bits can only be reset on POR.

2: When exiting Idle mode, there is a delay (TNPD) before Flash memory becomes operational.

3: All other combinations of NVMOP<3:0> are unimplemented.

4: The entire segment is erased with the exception of IVT.

5: Execution of the PWRSAV instruction is ignored while any of the NVM operations are in progress.

DS70619B-page 28 © 2009-2011 Microchip Technology Inc.

Page 29: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.5 Erasing Program MemoryThe procedure for erasing program memory (all of pri-mary Flash memory, auxiliary Flash memory, executivememory and code-protect Configuration bits) consistsof setting NVMCON to 0x400F and then executing theprogramming cycle. For segment erase operations, theNVMCON value should be modified suitably, accordingto Table 6-2.

Figure 6-6 shows the ICSP programming process forBulk Erasing program memory. This process includesthe ICSP command code, which must be transmitted(for each instruction) Least Significant bit first, using thePGC and PGD pins (see Figure 6-2).

FIGURE 6-6: BULK ERASE FLOW

TABLE 6-4: SERIAL INSTRUCTION EXECUTION FOR BULK ERASING CODE MEMORY

Note: Program memory must be erased beforewriting any data to program memory.

Start

End

Set the WR bit to Initiate Erase

Write 0x400F to NVMCON SFR

Delay P11 + P10 Time

Command(Binary)

Data(Hex) Description

Step 1: Exit the Reset vector.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

Step 2: Set the NVMCON to erase all program memory.0000000000000000

2400EA88394A000000000000

MOV #0x400F, W10MOV W10, NVMCONNOPNOP

Step 3: Initiate the erase cycle.00000000000000000000000000000000

200551883971200AA1883971A8E729000000000000000000

MOV #0x55, W1MOV W1, NVMKEYMOV #0xAA, W1MOV W1, NVMKEYBSET NVMCON, #WRNOPNOPNOP

Step 4: Wait for Bulk Erase operation to complete and make sure WR bit is clear.— — Externally time ‘P11’ msec (see Section 9.0 “AC/DC Characteristics and

Timing Requirements”) to allow sufficient time for the Bulk Erase operation to complete.

© 2009-2011 Microchip Technology Inc. DS70619B-page 29

Page 30: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.6 Writing Code MemoryThe procedure for writing code memory (primary orauxiliary Flash) is similar to the procedure for writingthe Configuration registers, except that 128 instructionwords are programmed at a time. To facilitate this oper-ation, working registers, W0:W5, are used astemporary holding registers for the data to beprogrammed.

Table 6-5 shows the ICSP programming details,including the serial pattern with the ICSP commandcode, which must be transmitted Least Significant bitfirst using the PGC and PGD pins (see Figure 6-2). InStep 1, the Reset vector is exited.

To minimize the programming time, the same packedinstruction format that the programming executive usesis utilized (Figure 5-4). In Step 2, the pointer andTBLPAG register are configured to point to the start ofthe latch block (0xFA0000). In Step 3, four packedinstruction words are stored in working registers,W0:W5, using the MOV instruction and the read pointer,W6, is initialized. The contents of W0:W5 holding thepacked instruction word data are shown in Figure 6-7.In Step 4, eight TBLWT instructions are used to copy thedata from W0:W5 to the write latches. Since codememory is programmed 128 instruction words at atime, Steps 3-4 are repeated 32 times to load all thewrite latches (Step 5). The NVMADRU/NVMADR regis-ter-pair are then initialized to point to the correct rowaddress.

After the write latches are loaded, programming isinitiated by writing to the NVMCON register in Step 7 andsetting the WR bit in Step 8. In Step 9, the internal PC isreset to 0x200 every time the NVMCON register isinspected for polling the WR bit. This is a precautionarymeasure to prevent the PC from incrementing into unim-plemented memory when large devices are being pro-grammed. Lastly, in Step 10, Steps 2-9 are repeated untilall of code memory is programmed.

FIGURE 6-7: PACKED INSTRUCTION WORDS IN W0:W5

15 8 7 0

W0 LSW0W1 MSB1 MSB0W2 LSW1W3 LSW2W4 MSB3 MSB2W5 LSW3

TABLE 6-5: SERIAL INSTRUCTION EXECUTION FOR WRITING CODE MEMORY (PRIMARY OR AUXILIARY FLASH)

Command(Binary)

Data(Hex) Description

Step 1: Exit the Reset vector.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

Step 2: Initialize the write pointer and TBLPAG register for writing to latches.000000000000

200FAC8802AC200007

MOV #0xFA, W12MOV W12, TBLPAGMOV #0, W7

Step 3: Initialize the read pointer (W6) and load W0:W5 with the next 4 instruction words to program.000000000000000000000000

2xxxx02xxxx12xxxx22xxxx32xxxx42xxxx5

MOV #<LSW0>, W0MOV #<MSB1:MSB0>, W1MOV #<LSW1>, W2MOV #<LSW2>, W3MOV #<MSB3:MSB2>, W4MOV #<LSW3>, W5

DS70619B-page 30 © 2009-2011 Microchip Technology Inc.

Page 31: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 4: Set the read pointer (W6) and load the (next set of) write latches.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

EB0300000000BB0BB6000000000000BBDBB6000000000000BBEBB6000000000000BB1BB6000000000000BB0BB6000000000000BBDBB6000000000000BBEBB6000000000000BB1BB6000000000000

CLR W6NOPTBLWTL[W6++], [W7] NOPNOPTBLWTH.B[W6++], [W7++] NOPNOPTBLWTH.B[W6++], [++W7] NOPNOPTBLWTL[W6++], [W7++] NOP NOPTBLWTL[W6++], [W7] NOPNOPTBLWTH.B[W6++], [W7++] NOP NOPTBLWTH.B[W6++], [++W7] NOPNOPTBLWTL[W6++], [W7++] NOPNOP

Step 5: Repeat steps 3-4 thirty-two times to load the write latches for 128 instructions.Step 6: Set the NVMADRU/NVMADR register-pair to point to the correct row.

0000000000000000

2xxxx22xxxx3883963883952

MOV #DestinationAddress<15:0>, W2MOV #DestinationAddress<23:16>, W3MOV W3, NVMADRUMOV W2, NVMADR

Step 7: Set the NVMCON to program 128 instruction words.0000000000000000

24002A88394A000000000000

MOV #0x4002, W10MOV W10, NVMCONNOPNOP

Step 8: Initiate the write cycle.0000000000000000000000000000000000000000

200551883971200AA1883971A8E729000000000000000000000000000000

MOV #0x55, W1MOV W1, NVMKEYMOV #0xAA, W1MOV W1, NVMKEYBSET NVMCON, #WRNOP(1)

NOP(1)

NOP(1)

NOP(1)

NOP(1)

TABLE 6-5: SERIAL INSTRUCTION EXECUTION FOR WRITING CODE MEMORY (PRIMARY OR AUXILIARY FLASH) (CONTINUED)

Command(Binary)

Data(Hex) Description

© 2009-2011 Microchip Technology Inc. DS70619B-page 31

Page 32: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 9: Wait for Row Program operation to complete and make sure WR bit is clear.—

0000000000000000000000010000000000000000000000000000

000000803940000000887C40000000<VISI>000000000000000000040200000000000000000000

Externally time ‘P13’ msec (see Section 9.0 “AC/DC Characteristics and Timing Requirements”) to allow sufficient time for the Row Program operation to complete.NOPMOV NVMCON, W0NOPMOV W0, VISINOPClock out contents of VISI register.NOPNOPNOPGOTO 0x200NOPNOPNOPRepeat until the WR bit is clear.

Step 10: Repeat steps 2-9 until all code memory is programmed.Note 1: These three NOP instructions must be transmitted with a clock frequency greater than 2 MHz.

TABLE 6-5: SERIAL INSTRUCTION EXECUTION FOR WRITING CODE MEMORY (PRIMARY OR AUXILIARY FLASH) (CONTINUED)

Command(Binary)

Data(Hex) Description

DS70619B-page 32 © 2009-2011 Microchip Technology Inc.

Page 33: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

FIGURE 6-8: PROGRAM CODE MEMORY FLOW

Start Write Sequence

Alllocations

done?

No

End

Start

Yes

Load 2 Bytesto Write

Buffer at <Addr>

Allbytes

written?No

Yes

and Poll for WR bitto be cleared

N = 1LoopCount = 0

ConfigureDevice for

Writes

N = 1LoopCount =

LoopCount + 1

N = N + 1

© 2009-2011 Microchip Technology Inc. DS70619B-page 33

Page 34: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.7 Writing Configuration MemoryThe 8-bit Configuration registers are programmable, oneregister at a time. The default programming valuesrecommended for the Configuration registers are shownin Table 6-6. The recommended default FOSCSEL valueis 0x87, which selects the FRC clock oscillator setting.Just like code memory, Configuration registers are pro-grammed by first setting up the programmed value in alatch (located at address 0xFA0000), specifying theconfiguration register address in the NVMADRU andNVMADR registers, and then initiating a configurationwrite operation.

The FGS and FAS Configuration registers are specialsince they enable code protection for the device. Forsecurity purposes, once any bit in these registers isprogrammed to ‘0’ (to enable code protection), it canonly be set back to ‘1’ by performing a Bulk Erase asdescribed in Section 6.5 “Erasing ProgramMemory”.

TABLE 6-6: DEFAULT CONFIGURATION REGISTER VALUESAddress Name Default Value

0xF80004 FGS 0x030xF80006 FOSCSEL 0x870xF80008 FOSC 0xE70xF8000A FWDT 0xFF0xF8000C FPOR 0x3F0xF8000E FICD 0xD70xF80010 FAS 0x030xF80012 FUID0 0xFF

TABLE 6-7: SERIAL INSTRUCTION EXECUTION FOR WRITING CONFIGURATION REGISTERS

Command(Binary)

Data(Hex) Description

Step 1: Exit the Reset vector.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

Step 2: Initialize the write pointer for writing to the latches.0000 200007 MOV #0x0000, W7

Step 3: Initialize the TBLPAG register for writing to the latches.00000000

200FAC8802AC

MOV #0xFA, W12MOV W12, TBLPAG

Step 4: Load the Configuration register data to W6.0000 2xxxx0 MOV #<CONFIG_VALUE>, W0

Step 5: Write the Configuration register data to the write latch and increment the write pointer.000000000000

BB0B80000000000000

TBLWTL W0, [W7]NOPNOP

Step 6: Set the NVMADRU/NVMADR register-pair to point to the Configuration register.0000000000000000

2xxxx22xxxx3883963883952

MOV #DestinationAddress<15:0>, W2MOV #DestinationAddress<23:16>, W3MOV W3, NVMADRUMOV W2, NVMADR

DS70619B-page 34 © 2009-2011 Microchip Technology Inc.

Page 35: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 7: Set the NVMCON register to program one Configuration register.0000000000000000

24000A88394A000000000000

MOV #0x4000, W10MOV W10, NVMCONNOPNOP

Step 8: Initiate the write cycle.00000000000000000000000000000000

200551883971200AA1883971A8E729000000000000000000

MOV #0x55, W1MOV W1, NVMKEYMOV #0xAA, W1MOV W1, NVMKEYBSET NVMCON, #WRNOPNOPNOP

Step 9: Wait for the Configuration Register Write operation to complete and make sure WR bit is clear.—

0000000000000000000000010000000000000000000000000000

000000803940000000887C40000000<VISI>000000000000000000040200000000000000000000

Externally time ‘P20’ msec (see Section 9.0 “AC/DC Characteristics and Timing Requirements”) to allow sufficient time for the Configuration Register Write operation to complete.NOPMOV NVMCON, W0NOPMOV W0, VISINOPClock out contents of VISI register.NOPNOPNOPGOTO 0x200NOPNOPNOPRepeat until the WR bit is clear.

Step 10: Repeat steps 4-9 until all eight Configuration registers are written.

TABLE 6-7: SERIAL INSTRUCTION EXECUTION FOR WRITING CONFIGURATION REGISTERS (CONTINUED)

Command(Binary)

Data(Hex) Description

© 2009-2011 Microchip Technology Inc. DS70619B-page 35

Page 36: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.8 Reading Code MemoryReading from code memory (primary or auxiliary Flash)is performed by executing a series of TBLRD instruc-tions and clocking out the data using the REGOUTcommand.

Table 6-8 shows the ICSP programming details forreading code memory. In Step 1, the Reset vector isexited. In Step 2, the 24-bit starting source address forreading is loaded into the TBLPAG register and W6register. The upper byte of the starting source addressis stored in TBLPAG and the lower 16 bits of the sourceaddress are stored in W6.

To minimize the reading time, the packed instructionword format that was utilized for writing is also used forreading (see Figure 6-7). In Step 3, the write pointer,W7, is initialized. In Step 4, two instruction words areread from code memory and clocked out of the device,through the VISI register, using the REGOUT command.Step 4 is repeated until the desired amount of codememory is read.

TABLE 6-8: SERIAL INSTRUCTION EXECUTION FOR READING CODE MEMORY(PRIMARY OR AUXILIARY FLASH)

Command(Binary)

Data(Hex) Description

Step 1: Exit the Reset vector.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

Step 2: Initialize TBLPAG and the read pointer (W6) for TBLRD instruction.000000000000

200xx08802A02xxxx6

MOV #<SourceAddress23:16>, W0MOV W0, TBLPAGMOV #<SourceAddress15:0>, W6

DS70619B-page 36 © 2009-2011 Microchip Technology Inc.

Page 37: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 3: Initialize the write pointer (W7) and store the next four locations of code memory to W0:W5.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

EB0380000000BA1B96000000000000000000000000000000BADBB6000000000000000000000000000000BADBD6000000000000000000000000000000BA1BB6000000000000000000000000000000BA1B96000000000000000000000000000000BADBB6000000000000000000000000000000BADBD6000000000000000000000000000000BA0BB6000000000000000000000000000000

CLR W7 NOPTBLRDL [W6], [W7++] NOPNOPNOPNOPNOPTBLRDH.B [W6++], [W7++] NOPNOPNOPNOPNOPTBLRDH.B [++W6], [W7++] NOPNOPNOPNOPNOPTBLRDL [W6++], [W7++] NOPNOPNOPNOPNOPTBLRDL [W6], [W7++] NOPNOPNOPNOPNOPTBLRDH.B [W6++], [W7++] NOPNOPNOPNOPNOPTBLRDH.B [++W6], [W7++] NOPNOPNOPNOPNOPTBLRDL [W6++], [W7] NOPNOPNOPNOPNOP

TABLE 6-8: SERIAL INSTRUCTION EXECUTION FOR READING CODE MEMORY(PRIMARY OR AUXILIARY FLASH) (CONTINUED)

Command(Binary)

Data(Hex) Description

© 2009-2011 Microchip Technology Inc. DS70619B-page 37

Page 38: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 4: Output W0:W5 using the VISI register and REGOUT command.000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000

887C40000000<VISI>000000887C41000000<VISI>000000887C42000000<VISI>000000887C43000000<VISI>000000887C44000000<VISI>000000887C45000000<VISI>000000

MOV W0, VISI NOPClock out contents of VISI register.NOPMOV W1, VISI NOPClock out contents of VISI register.NOPMOV W2, VISI NOPClock out contents of VISI register.NOPMOV W3, VISI NOPClock out contents of VISI register.NOPMOV W4, VISI NOPClock out contents of VISI register.NOPMOV W5, VISI NOPClock out contents of VISI register.NOP

Step 5: Repeat step 4 until all desired code memory is read.Step 6: Reset device internal PC.

0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200 NOPNOPNOP

TABLE 6-8: SERIAL INSTRUCTION EXECUTION FOR READING CODE MEMORY(PRIMARY OR AUXILIARY FLASH) (CONTINUED)

Command(Binary)

Data(Hex) Description

DS70619B-page 38 © 2009-2011 Microchip Technology Inc.

Page 39: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.9 Reading Configuration MemoryThe procedure for reading configuration memory issimilar to the procedure for reading code memory,except that 16-bit data words are read (with the upperbyte read being all ‘0’s) instead of 24-bit words. Sincethere are eight Configuration registers, they are readone register at a time.

Table 6-9 shows the ICSP programming details forreading all of the configuration memory. Note that theTBLPAG register is hard coded to 0xF8 (the upper byteaddress of configuration memory) and the read pointer,W6, is initialized to 0x0004.

TABLE 6-9: SERIAL INSTRUCTION EXECUTION FOR READING ALL CONFIGURATION MEMORYCommand(Binary)

Data(Hex) Description

Step 1: Exit the Reset vector.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

Step 2: Initialize TBLPAG, the read pointer (W6) and the write pointer (W7) for TBLRD instruction.00000000000000000000

200F808802A020004620F887000000

MOV #0xF8, W0MOV W0, TBLPAGMOV #0x04, W6MOV #VISI, W7NOP

Step 3: Read the Configuration register and write it to the VISI register (located at 0x784) and clock out the VISI register using the REGOUT command.

0000000000000000000000000001

BA0BB6000000000000000000000000000000<VISI>

TBLRDL [W6++], [W7]NOPNOPNOPNOPNOPClock out contents of VISI register.

Step 4: Repeat step 3 eight times to read all the Configuration registers.Step 5: Reset device internal PC.

0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

© 2009-2011 Microchip Technology Inc. DS70619B-page 39

Page 40: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

6.10 Verify Code Memory and Configuration Word

The verify step involves reading back the code memoryspace and comparing it against the copy held in theprogrammer’s buffer. The Configuration registers areverified with the rest of the code.

The verify process is shown in the flowchart inFigure 6-9. Memory reads occur a single byte at a time,so two bytes must be read to compare against the wordin the programmer’s buffer. Refer to Section 6.8“Reading Code Memory” for implementation detailsof reading code memory.

FIGURE 6-9: VERIFY CODE MEMORY FLOW

6.11 Reading the Application ID WordThe Application ID Word is stored at address 0x8007F0in executive code memory. To read this memorylocation, you must use the SIX control code to movethis program memory location to the VISI register.Then, the REGOUT control code must be used to clockthe contents of the VISI register out of the device. Thecorresponding control and instruction codes that mustbe serially transmitted to the device to perform thisoperation are shown in Table 6-10.

After the programmer has clocked out the ApplicationID Word, it must be inspected. If the application ID hasthe value 0xDD, the programming executive is residentin memory and the device can be programmed usingthe mechanism described in Section 3.0 “DeviceProgramming – Enhanced ICSP”. However, if theapplication ID has any other value, the programmingexecutive is not resident in memory; it must be loadedto memory before the device can be programmed. Theprocedure for loading the programming executive tomemory is described in Section 7.0 “Programmingthe Programming Executive to Memory”.

6.12 Exiting ICSP ModeExiting Program/Verify mode is done by removing VIHfrom MCLR, as shown in Figure 6-10. The onlyrequirement for exit is that an interval P16 shouldelapse between the last clock and program signals onPGC and PGD before removing VIH.

FIGURE 6-10: EXITING ICSP™ MODE

Note: Because the Configuration registersinclude the device code protection bit,code memory should be verifiedimmediately after writing, if the codeprotection is enabled. This is because thedevice will not be readable or verifiable ifa device Reset occurs after the code-pro-tect bit in the FGS or FAS Configurationregister has been cleared.

Read Low Byte

Read High Byte

DoesWord = Expect

Data?

Allcode memory

verified?

No

Yes

No

Set TBLPTR = 0

Start

Yes

End

with Post-Increment

with Post-Increment

FailureReport Error

MCLR

P16

PGD

PGD = Input

PGC

VDD

VIH

VIH

P17

DS70619B-page 40 © 2009-2011 Microchip Technology Inc.

Page 41: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

TABLE 6-10: SERIAL INSTRUCTION EXECUTION FOR READING THE APPLICATION ID WORDCommand(Binary)

Data(Hex) Description

Step 1: Exit the Reset vector.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

Step 2: Initialize TBLPAG and the read pointer (W0) for TBLRD instruction.00000000000000000000000000000000000000000000

2008008802A0207F0020F881000000BA0890000000000000000000000000000000

MOV #0x80, W0 MOV W0, TBLPAGMOV #0x7F0, W0 MOV #VISI, W1 NOP TBLRDL [W0], [W1] NOPNOPNOPNOPNOP

Step 3: Output the VISI register using the REGOUT command.0001 <VISI> Clock out contents of the VISI register.

© 2009-2011 Microchip Technology Inc. DS70619B-page 41

Page 42: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

7.0 PROGRAMMING THE PROGRAMMING EXECUTIVE TO MEMORY

7.1 OverviewIf it is determined that the programming executive is notpresent in executive memory (as described inSection 3.2 “Confirming the Presence of the

Programming Executive”), it must be programmedinto executive memory using ICSP, as described inSection 6.0 “Device Programming – ICSP”.

Storing the programming executive to executivememory is similar to normal programming of codememory. Namely, the executive memory must first beerased, and then the programming executive must beprogrammed 128 words at a time. This control flow issummarized in Table 7-1.

TABLE 7-1: PROGRAMMING THE PROGRAMMING EXECUTIVECommand(Binary)

Data(Hex) Description

Step 1: Exit the Reset vector and erase executive memory.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

Step 2: Initialize the NVMCON to erase a page of executive memory.0000000000000000

24003A88394A000000000000

MOV #0x4003, W10MOV W10, NVMCONNOPNOP

Step 3: Initiate the erase cycle, wait for erase to complete and make sure WR bit is clear.00000000000000000000000000000000000000000000000000000000

000000000000000000000001

200083883963200002883952000000000000200551883971200AA1883971A8E729000000000000000000

000000803940000000887C40000000<VISI>

MOV #0x80, W3MOV W3, NVMADRUMOV #0x00, W2MOV W2, NVMADRNOPNOPMOV #0x55, W1MOV W1, NVMKEYMOV #0xAA, W1MOV W1, NVMKEYBSET NVMCON, #15NOPNOPNOPExternally time ‘P12’ msec (see Section 9.0 “AC/DC Characteristics and Timing Requirements”) to allow sufficient time for the Page Erase operation to complete.NOPMOV NVMCON, W0NOPMOV W0, VISINOPClock out contents of VISI register. Repeat until the WR bit is clear.

Step 4: Repeat Step 3 to erase the second page of executive memory (modifying NVMADR suitably). Step 5: Initialize the NVMCON to program 128 instruction words.

00000000

24002A88394A

MOV #0x4002, W10 MOV W10, NVMCON

DS70619B-page 42 © 2009-2011 Microchip Technology Inc.

Page 43: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 6: Initialize TBLPAG, the write pointer (W7), NVMADRU and NVMADR for each row.00000000000000000000000000000000

2008038802A02xxxx2883952200FAC8802ACEB0380000000

MOV #0x80, W3MOV W3, NVMADRUMOV #DestinationAddress<15:0>, W2MOV W2, NVMADRMOV #0xFA, W12MOV W12, TBLPAGCLR W7 NOP

Step 7: Load W0:W5 with the next 4 words of packed programming executive code and initialize W6 for programming. Programming starts from the base of executive memory (0x800000) using W6 as a read pointer and W7 as a write pointer.

000000000000000000000000

2<LSW0>02<MSB1:MSB0>12<LSW1>22<LSW2>32<MSB3:MSB2>42<LSW3>5

MOV #<LSW0>, W0 MOV #<MSB1:MSB0>, W1 MOV #<LSW1>, W2 MOV #<LSW2>, W3 MOV #<MSB3:MSB2>, W4 MOV #<LSW3>, W5

Step 8: Set the read pointer (W6) and load the (next four write) latches.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

EB0300000000BB0BB6000000000000BBDBB6000000000000BBEBB6000000000000BB1BB6000000000000BB0BB6000000000000BBDBB6000000000000BBEBB6000000000000BB1BB6000000000000

CLR W6NOPTBLWTL [W6++], [W7] NOPNOPTBLWTH.B[W6++], [W7++] NOPNOPTBLWTH.B[W6++], [++W7] NOPNOPTBLWTL [W6++], [W7++] NOPNOPTBLWTL [W6++], [W7] NOPNOPTBLWTH.B[W6++], [W7++] NOPNOPTBLWTH.B[W6++], [++W7] NOPNOPTBLWTL [W6++], [W7++] NOPNOP

Step 9: Repeat Steps 7-8 thirty-two times to load the write latches for the 128 instructions.

TABLE 7-1: PROGRAMMING THE PROGRAMMING EXECUTIVE (CONTINUED)Command(Binary)

Data(Hex) Description

© 2009-2011 Microchip Technology Inc. DS70619B-page 43

Page 44: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 10: Initiate the programming cycle.0000000000000000000000000000000000000000

200551883971200AA1883971A8E729000000000000000000000000000000

MOV #0x55, W1MOV W1, NVMKEYMOV #0xAA, W1MOV W1, NVMKEYBSET NVMCON, #15 NOP(1)

NOP(1)

NOP(1)

NOP(1)

NOP(1)

Step 11: Wait for the Row Program operation to complete.—

0000000000000000000000010000000000000000000000000000

000000803940000000887C40000000<VISI>000000000000000000040200000000000000000000

Externally time ‘P13’ msec (see Section 9.0 “AC/DC Characteristics and Timing Requirements”) to allow sufficient time for the Row Program operation to complete.NOPMOV NVMCON, W0NOPMOV W0, VISINOPClock out contents of VISI register.NOPNOPNOPGOTO 0x200 NOPNOPNOPRepeat until the WR bit is clear.

Step 12: Repeat Steps 6-11 until all 16 rows of executive memory have been programmed. Note 1: These three NOP instructions must be transmitted with a clock frequency greater than 2 MHz.

TABLE 7-1: PROGRAMMING THE PROGRAMMING EXECUTIVE (CONTINUED)Command(Binary)

Data(Hex) Description

DS70619B-page 44 © 2009-2011 Microchip Technology Inc.

Page 45: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

7.2 Programming Verification After the programming executive has beenprogrammed to executive memory using ICSP, it mustbe verified. Verification is performed by reading out thecontents of executive memory and comparing it withthe image of the programming executive stored in theprogrammer.

Reading the contents of executive memory can beperformed using the same technique described inSection 6.8 “Reading Code Memory”. A procedurefor reading executive memory is shown in Table 7-2.Note that in Step 2, the TBLPAG register is set to 0x80,such that executive memory may be read.

TABLE 7-2: READING EXECUTIVE MEMORYCommand(Binary)

Data(Hex) Description

Step 1: Exit the Reset vector.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200NOPNOPNOP

Step 2: Initialize TBLPAG and the read pointer (W6) for TBLRD instruction.000000000000

2008008802A0EB0300

MOV #0x80, W0 MOV W0, TBLPAGCLR W6

© 2009-2011 Microchip Technology Inc. DS70619B-page 45

Page 46: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 3: Initialize the write pointer (W7) and store the next four locations of code memory to W0:W5.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

EB0380000000BA1B96000000000000000000000000000000BADBB6000000000000000000000000000000BADBD6000000000000000000000000000000BA1BB6000000000000000000000000000000BA1B96000000000000000000000000000000BADBB6000000000000000000000000000000BADBD6000000000000000000000000000000BA0BB6000000000000000000000000000000

CLR W7 NOPTBLRDL [W6], [W7++] NOPNOPNOPNOPNOPTBLRDH.B [W6++], [W7++] NOPNOPNOPNOPNOPTBLRDH.B [++W6], [W7++] NOPNOPNOPNOPNOPTBLRDL [W6++], [W7++] NOPNOPNOPNOPNOPTBLRDL [W6], [W7++] NOPNOPNOPNOPNOPTBLRDH.B [W6++], [W7++] NOPNOPNOPNOPNOPTBLRDH.B [++W6], [W7++] NOPNOPNOPNOPNOPTBLRDL [W6++], [W7] NOPNOPNOPNOPNOP

TABLE 7-2: READING EXECUTIVE MEMORY (CONTINUED)Command(Binary)

Data(Hex) Description

DS70619B-page 46 © 2009-2011 Microchip Technology Inc.

Page 47: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

Step 4: Output W0:W5 using the VISI register and REGOUT command.000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000

887C40000000<VISI>000000887C41000000<VISI>000000887C42000000<VISI>000000887C43000000<VISI>000000887C44000000<VISI>000000887C45000000<VISI>000000

MOV W0, VISI NOPClock out contents of VISI register.NOPMOV W1, VISI NOPClock out contents of VISI register.NOPMOV W2, VISI NOPClock out contents of VISI register.NOPMOV W3, VISI NOPClock out contents of VISI register.NOPMOV W4, VISI NOPClock out contents of VISI register.NOPMOV W5, VISI NOPClock out contents of VISI register.NOP

Step 5: Reset the device internal PC.0000000000000000000000000000

000000000000000000040200000000000000000000

NOPNOPNOPGOTO 0x200 NOPNOPNOP

Step 6: Repeat Steps 4-5 until all 2048 instruction words of executive memory are read.

TABLE 7-2: READING EXECUTIVE MEMORY (CONTINUED)Command(Binary)

Data(Hex) Description

© 2009-2011 Microchip Technology Inc. DS70619B-page 47

Page 48: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

8.0 DEVICE IDThe device ID region of memory can be used todetermine mask, variant and manufacturinginformation about the chip. The device ID region is2 x 16 bits and it can be read using the READCcommand. This region of memory is read-only and canalso be read when code protection is enabled.

Table 8-1 lists the identification information for eachdevice.

Table 8-2 shows the Device ID registers.

Register 8-1 provides the JTAG ID register format.

TABLE 8-2: dsPIC33E/PIC24E PROGRAMMING SPECIFICATION DEVICE ID REGISTERS

REGISTER 8-1: JTAG ID REGISTER

TABLE 8-1: DEVICE IDs AND REVISION Device DEVID Register Value DEVREV Register Value Silicon Revision

dsPIC33EP256MU806 0x185A

0x4002 B1

dsPIC33EP256MU810 0x1862dsPIC33EP256MU814 0x1863PIC24EP256GU810 0x1826PIC24EP256GU814 0x1827dsPIC33EP512GP806 0x187DdsPIC33EP512MC806 0x1879dsPIC33EP512MU810 0x1872dsPIC33EP512MU814 0x1873PIC24EP512GP806 0x183DPIC24EP512GU810 0x1836PIC24EP512GU814 0x1837

Address NameBit

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0xFF0000 DEVID DEVID Value

0xFF0002 DEVREV DEVREV Value

31 28 27 12 11 0

DEVREV<3:0> DEVID<15:0> Manufacturer ID (0x053)

4 bits 16 bits 12 bits

DS70619B-page 48 © 2009-2011 Microchip Technology Inc.

Page 49: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

9.0 AC/DC CHARACTERISTICS AND TIMING REQUIREMENTS

Table 9-1 lists the AC/DC characteristics and timingrequirements.

TABLE 9-1: AC/DC CHARACTERISTICS AND TIMING REQUIREMENTS

Standard Operating ConditionsOperating Temperature: –40° C-85° C. Programming at 25° C is recommended.

Param. No. Symbol Characteristic Min. Max. Units Conditions

D111 VDD Supply Voltage During Programming 3.00 3.60 V Normal programming(1)

D112 IPP Programming Current on MCLR — 5 μA —D113 IDDP Supply Current During Programming — 10 mA —D114 IPP Instantaneous Peak Current During

Start-up— 200 mA —

D031 VIL Input Low Voltage VSS 0.2 VDD V —D041 VIH Input High Voltage 0.8 VDD VDD V —D080 VOL Output Low Voltage — 0.4 V IOL = 8 mA @ 3.3VD090 VOH Output High Voltage 2.4 — V IOH = 8 mA @ 3.3VD012 CIO Capacitive Loading on I/O pin (PGD) — 50 pF To meet AC specificationsP1 TPGC Serial Clock (PGC) Period (ICSP™) 200 — ns —P1 TPGC Serial Clock (PGC) Period (Enhanced

ICSP)500 — ns —

P1A TPGCL Serial Clock (PGC) Low Time (ICSP) 80 — ns —P1A TPGCL Serial Clock (PGC) Low Time (Enhanced

ICSP)200 — ns —

P1B TPGCH Serial Clock (PGC) High Time (ICSP) 80 — ns —P1B TPGCH Serial Clock (PGC) High Time (Enhanced

ICSP)200 — ns —

P2 TSET1 Input Data Setup Time to PGC ↓ 15 — ns —P3 THLD1 Input Data Hold Time from PGC ↓ 15 — ns —P4 TDLY1 Delay between 4-bit Command and

Command Operand40 — ns —

P4A TDLY1A Delay between Command Operand and Next 4-bit Command

40 — ns —

P5 TDLY2 Delay between Last PGC ↓ of Command to First PGC ↑ of Read of Data Word

20 — ns —

P6 TSET2 VDD ↑ Setup Time to MCLR ↑ 100 — ns —

P7 THLD2 Input Data Hold Time from MCLR ↑ 25 — ms —P8 TDLY3 Delay between Last PGC ↓ of Command

Byte to PGD ↑ by Programming Executive

12 — μs —

P9a TDLY4 Programming Executive Command Processing Time

10 — μs —

Note 1: VDD must also be supplied to the AVDD and VUSB pins during programming. AVDD and AVSS should alwaysbe within ±0.3V of VDD and VSS, respectively.

2: Time depends on the FRC accuracy and the value of the FRC Oscillator tuning register. Refer to the”Electrical Characteristics” chapter in the specific device data sheet.

© 2009-2011 Microchip Technology Inc. DS70619B-page 49

Page 50: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

P9b TDLY5 Delay between PGD ↓ by Programming Executive to PGD Released by Programming Executive

15 23 μs —

P10 TDLY6 PGC Low Time After Programming 400 — ns —P11 TDLY7 Bulk Erase Time

(primary and auxiliary Flash memory)84 116 ms See Note 2

P11a TDLY7a Bulk Erase Time (primary Flash memory) 50 70 ms See Note 2P11b TDLY7b Bulk Erase Time (auxiliary Flash memory) 50 70 ms See Note 2P12 TDLY8 Page Erase Time 17 23 ms See Note 2P13 TDLY9 Row Programming Time 1.2 1.6 ms See Note 2P14 TR MCLR Rise Time to Enter ICSP™ mode — 1.0 μs —P15 TVALID Data Out Valid from PGC ↑ 10 — ns —

P16 TDLY10 Delay between Last PGC ↓ and MCLR ↓ 0 — s —

P17 THLD3 MCLR ↓ to VDD ↓ 100 — ns —

P18 TKEY1 Delay from First MCLR ↓ to First PGC ↑ for Key Sequence on PGD

1 — ms —

P19 TKEY2 Delay from Last PGC ↓ for Key Sequence on PGD to Second MCLR ↑

25 — ns —

P20 TDLY11 Maximum Wait Time for Configuration Register Programming

— 25 ms —

P21 TMCLRH MCLR High Time — 500 μs —

TABLE 9-1: AC/DC CHARACTERISTICS AND TIMING REQUIREMENTS (CONTINUED)

Standard Operating ConditionsOperating Temperature: –40° C-85° C. Programming at 25° C is recommended.

Param. No. Symbol Characteristic Min. Max. Units Conditions

Note 1: VDD must also be supplied to the AVDD and VUSB pins during programming. AVDD and AVSS should alwaysbe within ±0.3V of VDD and VSS, respectively.

2: Time depends on the FRC accuracy and the value of the FRC Oscillator tuning register. Refer to the”Electrical Characteristics” chapter in the specific device data sheet.

DS70619B-page 50 © 2009-2011 Microchip Technology Inc.

Page 51: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

APPENDIX A: HEX FILE FORMATFlash programmers process the standard HEX formatused by the Microchip development tools. The formatsupported is the Intel® HEX32 Format (INHX32).Please refer to Appendix A in the “MPASM™ UsersGuide” (DS33014) for more information about hex fileformats.

The basic format of the hex file is:

:BBAAAATTHHHH...HHHHCC

Each data record begins with a 9-character prefix andalways ends with a 2-character checksum. All recordsbegin with ‘:’ regardless of the format. The individualelements are described below.

• BB – is a two-digit hexadecimal byte count representing the number of data bytes that appear on the line. Divide this number by two to get the number of words per line.

• AAAA – is a four-digit hexadecimal address representing the starting address of the data record. Format is high byte first followed by low byte. The address is doubled because this format only supports 8 bits. Divide the value by two to find the real device address.

• TT – is a two-digit record type that will be ‘00’ for data records, ‘01’ for end-of-file records and ‘04’ for extended-address record.

• HHHH – is a four-digit hexadecimal data word. Format is low byte followed by high byte. There will be BB/2 data words following TT.

• CC – is a two-digit hexadecimal checksum that is the two’s complement of the sum of all the preceding bytes in the line record.

Because the Intel hex file format is byte-oriented, andthe 16-bit program counter is not, program memorysections require special treatment. Each 24-bitprogram word is extended to 32 bits by inserting aso-called “phantom byte”. Each program memoryaddress is multiplied by 2 to yield a byte address.

As an example, a section that is located at 0x100 inprogram memory will be represented in the hex file as0x200.

The hex file will be produced with the followingcontents:

:020000040000fa

:040200003322110096

:00000001FF

Notice that the data record (line 2) has a load addressof 0200, while the source code specified address0x100. Note also that the data is represented in“little-endian” format, meaning the Least SignificantByte (LSB) appears first. The phantom byte appearslast, just before the checksum.

© 2009-2011 Microchip Technology Inc. DS70619B-page 51

Page 52: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

dsPIC33E/PIC24E PROGRAMMING SPECIFICATION

APPENDIX B: REVISION HISTORY

Revision A (December 2009)This is the initial released version of this document.

Revision B (June 2011)This revision includes the following updates:

• Updated Section 2.1 “Required Connections”• Added the VUSB pin reference to the list of Pin

Names and to Note 1 of Pins Used During Programming (Table 2-1)

• Removed Section 2.3 “Pins Used During Programming”

• Add the following devices to Code Memory Size (Table 2-2), Device IDs and Revision (Table 8-1):- dsPIC33EP512GP806- dsPIC33EP512MC806- PIC24EP512GP806

• Updated the Program Memory Map (Figure 2-2)• Updated the interval time in the next to last para-

graph of Section 3.3 “Entering Enhanced ICSP Mode”

• Updated Entering Enhanced ICSP™ Mode (Figure 3-3)

• Renumbered and updated Section 4.0 “Checksum Computation”

• Updated the interval time in the next to last para-graph of Section 6.2 “Entering ICSP Mode”

• Updated Entering ICSP™ Mode (Figure 6-5) • These changes were made to the AC/DC

Characteristics and Timing Requirements (Table 9-1):- Updated the Min value for parameter D111- Updated the Max value for parameter D113- Added parameter D114- Removed parameter D013- Updated the Max value and the conditions for

parameter D80- Updated the Min value and the conditions for

parameter D90- Updated the Min and Max values for parameter

P17- Updated the Units for parameter P18- Added the VUSB pin reference to Note 1

• Updates to formatting and minor text changes were incorporated throughout the document.

DS70619B-page 52 © 2009-2011 Microchip Technology Inc.

Page 53: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

Note the following details of the code protection feature on Microchip devices:• Microchip products meet the specification contained in their particular Microchip Data Sheet.

• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions.

• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property.

• Microchip is willing to work with the customer who is concerned about the integrity of their code.

• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”

Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of ourproducts. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such actsallow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.

Information contained in this publication regarding deviceapplications and the like is provided only for your convenienceand may be superseded by updates. It is your responsibility toensure that your application meets with your specifications.MICROCHIP MAKES NO REPRESENTATIONS ORWARRANTIES OF ANY KIND WHETHER EXPRESS ORIMPLIED, WRITTEN OR ORAL, STATUTORY OROTHERWISE, RELATED TO THE INFORMATION,INCLUDING BUT NOT LIMITED TO ITS CONDITION,QUALITY, PERFORMANCE, MERCHANTABILITY ORFITNESS FOR PURPOSE. Microchip disclaims all liabilityarising from this information and its use. Use of Microchipdevices in life support and/or safety applications is entirely atthe buyer’s risk, and the buyer agrees to defend, indemnify andhold harmless Microchip from any and all damages, claims,suits, or expenses resulting from such use. No licenses areconveyed, implicitly or otherwise, under any Microchipintellectual property rights.

© 2009-2011 Microchip Technology Inc.

Trademarks

The Microchip name and logo, the Microchip logo, dsPIC, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC32 logo, rfPIC and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.

FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A.

Analog-for-the-Digital Age, Application Maestro, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, UniWinDriver, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.

SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.

All other trademarks mentioned herein are property of their respective companies.

© 2009-2011, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.

Printed on recycled paper.

ISBN: 978-1-61341-316-6

DS70619B-page 53

Microchip received ISO/TS-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company’s quality system processes and procedures are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified.

Page 54: dsPIC33E/PIC24E Flash Programming Specificationww1.microchip.com/downloads/en/DeviceDoc/70619B.pdf · This document defines the programming specification for the dsPIC33E 16-bit Digital

DS70619B-page 54 © 2009-2011 Microchip Technology Inc.

AMERICASCorporate Office2355 West Chandler Blvd.Chandler, AZ 85224-6199Tel: 480-792-7200 Fax: 480-792-7277Technical Support: http://www.microchip.com/supportWeb Address: www.microchip.comAtlantaDuluth, GA Tel: 678-957-9614 Fax: 678-957-1455BostonWestborough, MA Tel: 774-760-0087 Fax: 774-760-0088ChicagoItasca, IL Tel: 630-285-0071 Fax: 630-285-0075ClevelandIndependence, OH Tel: 216-447-0464 Fax: 216-447-0643DallasAddison, TX Tel: 972-818-7423 Fax: 972-818-2924DetroitFarmington Hills, MI Tel: 248-538-2250Fax: 248-538-2260IndianapolisNoblesville, IN Tel: 317-773-8323Fax: 317-773-5453Los AngelesMission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608Santa ClaraSanta Clara, CA Tel: 408-961-6444Fax: 408-961-6445TorontoMississauga, Ontario, CanadaTel: 905-673-0699 Fax: 905-673-6509

ASIA/PACIFICAsia Pacific OfficeSuites 3707-14, 37th FloorTower 6, The GatewayHarbour City, KowloonHong KongTel: 852-2401-1200Fax: 852-2401-3431Australia - SydneyTel: 61-2-9868-6733Fax: 61-2-9868-6755China - BeijingTel: 86-10-8569-7000 Fax: 86-10-8528-2104China - ChengduTel: 86-28-8665-5511Fax: 86-28-8665-7889China - ChongqingTel: 86-23-8980-9588Fax: 86-23-8980-9500China - HangzhouTel: 86-571-2819-3180 Fax: 86-571-2819-3189China - Hong Kong SARTel: 852-2401-1200 Fax: 852-2401-3431China - NanjingTel: 86-25-8473-2460Fax: 86-25-8473-2470China - QingdaoTel: 86-532-8502-7355Fax: 86-532-8502-7205China - ShanghaiTel: 86-21-5407-5533 Fax: 86-21-5407-5066China - ShenyangTel: 86-24-2334-2829Fax: 86-24-2334-2393China - ShenzhenTel: 86-755-8203-2660 Fax: 86-755-8203-1760China - WuhanTel: 86-27-5980-5300Fax: 86-27-5980-5118China - XianTel: 86-29-8833-7252Fax: 86-29-8833-7256China - XiamenTel: 86-592-2388138 Fax: 86-592-2388130China - ZhuhaiTel: 86-756-3210040 Fax: 86-756-3210049

ASIA/PACIFICIndia - BangaloreTel: 91-80-3090-4444 Fax: 91-80-3090-4123India - New DelhiTel: 91-11-4160-8631Fax: 91-11-4160-8632India - PuneTel: 91-20-2566-1512Fax: 91-20-2566-1513Japan - YokohamaTel: 81-45-471- 6166 Fax: 81-45-471-6122Korea - DaeguTel: 82-53-744-4301Fax: 82-53-744-4302Korea - SeoulTel: 82-2-554-7200Fax: 82-2-558-5932 or 82-2-558-5934Malaysia - Kuala LumpurTel: 60-3-6201-9857Fax: 60-3-6201-9859Malaysia - PenangTel: 60-4-227-8870Fax: 60-4-227-4068Philippines - ManilaTel: 63-2-634-9065Fax: 63-2-634-9069SingaporeTel: 65-6334-8870Fax: 65-6334-8850Taiwan - Hsin ChuTel: 886-3-6578-300Fax: 886-3-6578-370Taiwan - KaohsiungTel: 886-7-213-7830Fax: 886-7-330-9305Taiwan - TaipeiTel: 886-2-2500-6610 Fax: 886-2-2508-0102Thailand - BangkokTel: 66-2-694-1351Fax: 66-2-694-1350

EUROPEAustria - WelsTel: 43-7242-2244-39Fax: 43-7242-2244-393Denmark - CopenhagenTel: 45-4450-2828 Fax: 45-4485-2829France - ParisTel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79Germany - MunichTel: 49-89-627-144-0 Fax: 49-89-627-144-44Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781Netherlands - DrunenTel: 31-416-690399 Fax: 31-416-690340Spain - MadridTel: 34-91-708-08-90Fax: 34-91-708-08-91UK - WokinghamTel: 44-118-921-5869Fax: 44-118-921-5820

Worldwide Sales and Service

05/02/11