© 2005 Microchip Technology Inc. DS93003A-page 1
GS003
INTRODUCTION
This document describes useful options that facilitate
in-circuit debugging of dsPIC30F embedded
application programs.
MULTIPLE DEBUGGING CHANNELS
dsPIC30F Digital Signal Controllers use Microchip's
low-cost development tool, MPLAB® ICD 2 In-Circuit
Debugger for both programming and in-circuit debug-
ging. MPLAB ICD 2 provides a 5-pin interface to the
dsPIC30F device. These pins are: VDD, VSS, MCLR,
PGC/EMUC and PGD/EMUD. The PGC/EMUC and
PGD/EMUD pins are used to communicate clock and
data signals, respectively, between the MPLAB ICD 2
unit and t he dsPIC3 0F device during progr ammin g and
debuggi ng operations .
To give you flexibility in board layout, dsPIC30F DSC
devices provide multiple options for connecting the
MPLAB ICD 2 to your target board for in-circuit debug-
ging. dsPIC30F devices are available in packages
ranging from 18 to 80 pins. Devices in small packages
ofte n hav e seve ral pe rip hera l fu ncti ons mult ipl exed on
each pin (see Figure 1). In certain cases, the default
programming and debugging pin functions, PGC/
EMUC and PGD/EMUD, are multiplexed on pins that
may be us ed by other peripheral s like the I2C™, SPI™,
or UART modules. In such cases, the application is
able to use these pins for programming, however they
cannot be used for in-circuit debugging. In-circuit
debugging should then be performed using alternate
debugging channels, as listed in Table 1. You should
note that the device programming and connect opera-
tions using MPLAB ICD 2 will continue to require the
use of the PGC and PGD pins.
TABLE 1: DEBUGGING CHANNELS
FIGURE 1: TYPICAL ALTERNATE
DEBUGGING CHANNEL
Author: Hrushikesh (Rishi) Vasuki
Microchip Technology Pin Name Pin Function
EMUD
EMUC Default Debug Data pin
Default Debug Clock pin
EMUD1
EMUC1 Alternate Debug Channel #1 Data pin
Alternate Debug Channel #1 Clock pin
EMUD2
EMUC2 Alternate Debug Channel #2 Data pin
Alternate Debug Channel #2 Clock pin
EMUD3
EMUC3 Alternate Debug Channel #3 Data pin
Alternate Debug Channel #3 Clock pin
PGC/EMUC/SDA
*
PGD/EMUD/SCL
*
PGC
PGD
VDD
V
SS
VPP
VDD
VSS
MCLR
Program
Debug
ICD 2 Header dsPIC30F3012
EMUD3*
EMUC3*
To I2C™ Device
Switch
12
11
1
13
14
* Pin Multiplexing on dsPIC30F3012 (PDIP Package):
Pin Mult ipl exed Func tio ns
2EMUD3/AN0/VREF+/CN2/RB0
3EMUC3/AN1/VREF-/CN3/RB1
11 PGD/EMUD/AN6/U1TX/SDO1/SCL/CN6/RB4
12 PGC/EMUC/AN5/U1RX/SDI1/SDA/CN7/RB5
2
3
In-Circuit Debugging Interface Options with dsPIC DSC
GS003
DS93003A-page 2 © 2005 Microchip Technology Inc.
DESIGN PROCEDURE
To make use of these alternate debugging channels, a
few steps need to be taken:
1. Before you lay out your circuit board, decide
whether you will need to use alternate
debugging channels .
For instance, assume that an application run-
ning on a dsPIC30F3012 requires the SDA and
SCL pin functions to communicate via the I2C
protocol with other components on the board.
On the dsPIC30F3012 device, the SCL and
SDA pins (11 and 12) are multiplexed with the
default in-circuit debugging pins, EMUD and
EMUC, respectively. So, this application
requires an alternate in-circuit debugging
channel.
2. Select the alternate debugging channel to use
from EMUC1/EMUD1, EMUC2/EMUD2 or
EMUC3/EMUD3.
For the hypothetical application, assume that
pins 2 and 3 on the dsPIC30F3 012 a re avail able
for use during in-circuit debugging operations.
Thus, you would use EMUC3 and EMUD3 as
the alternate in-circuit debugging channel for
this application.
3. While designing your board, provide a connec-
tion between the PGC and PGD pins on the
MPLAB ICD 2 unit and the selected alternate
debugging channel, EMUC3 and EMUD3, as
shown by the switch in Figure 1.
4. Before downloading code (programming) into
the target device, you’ll need to set the configu-
ration bits dialog in MPLAB IDE to accurately
reflect the selected in-circuit debugging chan-
nel. MPLAB IDE, by default, uses the PGC/
EMUC and PGD/EMUD pins for programming
and debugging. For the hypothetical application
you’ll set the “COMM CHANNEL SELECT”
opti on t o “Us e EMU C3 a nd E MUD3 ”, as show n
in Figure 2. The configuration bits dialog is
invoked by selecting the Configure>Configura-
tion Bits menu in MPLAB IDE.
5. During a programming or connect operation
(with MPLAB ICD 2 selected as a Debugger),
the switch (or jumper) should be positioned so
that the MPLAB ICD 2 unit communicates with
the target dsPIC30F device via PGC and PGD
(pins 12 and 11, respectively).
6. When programming is complete, the switch (or
jumper) should be positioned so that the MPLAB
ICD 2 unit communicates with the target
dsPIC30F d ev ic e v ia EMU C3 an d EM U D3 (p in s
3 and 2, respectiv el y).
7. You are now ready to perform in-circuit debug-
ging operations using such functions as Reset,
Run, Single-step, Halt, Set Breakpoint, etc.
FIGURE 2: EXAMPLE MPLAB® IDE CONFIGURATION BITS DIALOG
© 2005 Microchip Technology Inc. DS93003A-page 3
GS003
MPLAB ICD 2 ERROR HANDLING
If any of the steps detailed in this document were not
performed, MPLAB IDE may display an error message
such as shown in Figure 3.
This error message is displayed because MPLAB ICD
2 is no t able to commun icate with the D ebug Execu tive
running on the dsPIC® DSC. This communication fail-
ure occurs because the Debug Executive expects to
communicate with MPLAB ICD 2 on a channel (for
exampl e EMUC3 and EMU D3) differ ent from the boa rd
configuration (for example EMUC and EMUD).
FIGURE 3: EXAMPLE DEBUGGING ERROR ON INCORRECT CONFIGURATION
Programming Target...
...Validating configuration fields
...Erasing Pa rt
...Programming Programming Executive
...Verifying Programming Executive
...Programming Program Memory (0x0 - 0x53F)
Verifying...
...Program Memo ry
...Verify Succeeded
...Loading DebugExecutive
...Programming DebugExecutive
...Debug Executive
...Programming Debug Vector
...Debug Vector
...Programming Configuration Bits
.. Config Memory
Verifying configuration memory...
Connecting to debug executive
ICD0083: Target not in debug mode, unable to perform operation
MPLAB ICD 2 Ready
Error message displays if the
dsPIC30F device is not properly
configured for debugging.
GS003
DS93003A-page 4 © 2005 Microchip Technology Inc.
SUMMARY
This document described how alternate debugging
channels (EMUCx & EMUDx pins) can be used for in-
circuit debugging when the default debugging channel
(EMUC & EMUD pi ns) i s in use by the ap pl ication an d,
hence, rendered unavailable for use by MPLAB ICD 2.
Several dsPIC30F Development Boards, including
dsPICDEM™ MC1 and dsPICDEM 2, include jumpers
or switches that all ow you to select alt ernate debugging
channels.
For circuit details, see the schematics included in the
User’s Guides for these Development Boards
(dsPICDEM™ 1.1 Development Board Users Guide
(DS70099) and dsPICDEM™ 2 Development Board
User’s Guide (DS51558)).