# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# PIC24FJ32MC10X -- Programming and Diagnostics

- 1
- 2
- 3
- 4
…
- 11
- 12

PIC24F Family Reference Manual
DS39716A-page 33-2 Advance Information © 2006 Microchip Technology Inc.
33.1 INTRODUCTION
PIC24F devices provide a complete range of programming and diagnostic features that can
increase the flexibility of any application using them. These features allow system designers to
include:
• Simplified field programmability using two-wire interfaces
• Enhanced debugging capabilities
• Boundary scan testing for device and board diagnostics
PIC24F devices incorporate three different programming and diagnostic modalities that provide
a range of useful functions to the application developer. They are summarized in Table 33-1.
Table 33-1: Comparison of PIC24F Programming and Diagnostic Features
33.2 IN-CIRCUIT SERIAL PROGRAMMING™ (ICSP™)
In-Circuit Serial Programming (ICSP) is Microchip’s original solution to providing microcontroller
programming in the target application. Originally introduced for 8-bit PIC16 devices, it is used for
virtually all Microchip microcontrollers. ICSP is also the most direct method to program the
device, whether the controller is embedded in a system or loaded into a device programmer.
33.2.1 ICSP Interface
ICSP uses two pins as the core of its interface. The programming data line (PGD) functions as
both an input and an output, allowing programming data to be read in and device information to
be read out on command. The programming clock line (PGC) is used to clock in data and control
the overall process.
Most PIC24F devices have more than one pair of PGC and PGD pins; these are multiplexed with
other I/O or peripheral functions. Individual ICSP pin pairs are indicated by number (e.g.,
PGC1/PGD1, etc.), and are generically referred to as ‘PGCx’ and ‘PGDx’. The multiple
PGCx/PGDx pairs provide additional flexibility in system design by allowing users to incorporate
ICSP on the pair of pins that is least constrained by the circuit design. All PGCx and PGDx pins
are functionally tied together and behave identically, and any one pair can be used for successful
device programming. The only limitation is that both pins from the same pair must be used.
In addition to the PGCx and PGDx pins, ICSP requires that all voltage supply and ground pins
on the device must be connected, as well as voltage regulator pins (ENVREG or DISVREG). The
MCLR
pin, which is used with PGCx to enter and control the programming process, must also be
connected to the programming device.
33.2.2 ICSP Operation
ICSP uses a combination of internal hardware and external control to program the target device.
Programming data and instructions are provided on PGD. ICSP uses a special set of 4-bit
commands to control the overall process, combined with standard PIC24F instructions to exe-
cute the actual writing of the program memory. PGD also returns data to the external programmer
when responding to queries.
Control of the programming process is achieved by manipulating PGC and MCLR
. Entry into and
exit from Programming mode involves applying (or removing) voltage to MCLR
while supplying a
code sequence to PGD and a clock to PGC. Any one of the PGCx/PGDx pairs can be used to enter
programming. During programming, the clock train on PGC is also used to indicate the difference
between 4-bit commands, programming control commands and payload data to be programmed.
Feature Interface Device Integration Functions
ICSP™ PGCx and PGDx
pins
Integrated with device core Programming,
debugging
Enhanced ICSP
(EICSP)
Hardware integrated with device
core; firmware-based control
Programming
JTAG TDI, TDO, TMS
and TCK pins
Peripheral to device core, partly
integrated with I/O logic
Programming,
diagnostics (BST)

- 1
- 2
- 3
- 4
…
- 11
- 12