Section 24. Programming and Diagnostics

Similar documents
Section 24. Programming and Diagnostics

Section 24. Programming and Diagnostics

Using the XC9500/XL/XV JTAG Boundary Scan Interface

PIC18F2682/2685/4682/4685

12. IEEE (JTAG) Boundary-Scan Testing for the Cyclone III Device Family

Testing Sequential Logic. CPE/EE 428/528 VLSI Design II Intro to Testing (Part 2) Testing Sequential Logic (cont d) Testing Sequential Logic (cont d)

Configurable Logic Cell (CLC)

Chapter 19 IEEE Test Access Port (JTAG)

Overview of BDM nc. The IEEE JTAG specification is also recommended reading for those unfamiliar with JTAG. 1.2 Overview of BDM Before the intr

IEEE Standard (JTAG) in the Axcelerator Family

Comparing JTAG, SPI, and I2C

Using IEEE Boundary Scan (JTAG) With Cypress Ultra37000 CPLDs

HCS08 SG Family Background Debug Mode Entry

3. Configuration and Testing

Y. Tsiatouhas. VLSI Systems and Computer Architecture Lab. Boundary Scan (JTAG ) 2

11. JTAG Boundary-Scan Testing in Stratix V Devices

Product Update. JTAG Issues and the Use of RT54SX Devices

18 Nov 2015 Testing and Programming PCBA s. 1 JTAG Technologies

SµMMIT E & LXE/DXE JTAG Testability for the SJ02 Die

Ilmenau, 9 Dec 2016 Testing and programming PCBA s. 1 JTAG Technologies

M89 FAMILY In-System Programmable (ISP) Multiple-Memory and Logic FLASH+PSD Systems for MCUs

MCP16301 High-Performance Low-Noise 5V Output Buck Converter Evaluation Board User s Guide

Manchester Encoder Using USART and CCL on ATtiny817

7 Nov 2017 Testing and programming PCBA s

Raspberry Pi debugging with JTAG

Tools to Debug Dead Boards

SignalTap Plus System Analyzer

STEVAL-ICB004V1. Advanced resistive touchscreen controller demonstration board based on the STMPE811. Features. Description

Core Independent Nightlight Using Configurable Custom Logic on ATtiny1617

Device 1 Device 2 Device 3 Device 4

STEVAL-CCM003V1. Graphic panel with ZigBee features based on the STM32 and SPZBE260 module. Features. Description

16 Dec Testing and Programming PCBA s. 1 JTAG Technologies

A Briefing on IEEE Standard Test Access Port And Boundary-Scan Architecture ( AKA JTAG )

JRC ( JTAG Route Controller ) Data Sheet

Debugging IDT S-RIO Gen2 Switches Using RapidFET JTAG

Multi-channel LED driver with integrated boost controller for medium, large LCD panel backlight based on LED7708 and STM32F103C6T6A

STEVAL-IME002V1. Multi-lead electrocardiogram (ECG) and body impedance demonstration board. Features. Description

the Boundary Scan perspective

Configuring FLASHlogic Devices

Unit V Design for Testability

SµMMIT E & LXE/DXE Built-In-Self-Test Functionality for the JA01 Die

UNIT IV CMOS TESTING. EC2354_Unit IV 1

STEVAL-ILL029V1. Front panel demonstration board based on the STLED325 and STM8S. Features. Description

ST-LINK/V2 in-circuit debugger/programmer for STM8 and STM32

JTAG Test Controller

XJTAG DFT Assistant for

Explorer Edition FUZZY LOGIC DEVELOPMENT TOOL FOR ST6

Lecture 17: Introduction to Design For Testability (DFT) & Manufacturing Test

STEVAL-CCH002V2. HDMI and video switches demonstration board. Features. Description

XJTAG DFT Assistant for

Remote Diagnostics and Upgrades

STB Front Panel User s Guide

SMPTE-259M/DVB-ASI Scrambler/Controller

STEVAL-IHM043V1. 6-step BLDC sensorless driver board based on the STM32F051 and L6234. Features. Description

Entry Level Tool II. Reference Manual. System Level Solutions, Inc. (USA) Murphy Avenue San Martin, CA (408) Version : 1.0.

Digital Integrated Circuits Lecture 19: Design for Testability

L7208. Portable consumer electronics spindle and VCM motor controller. General features. Spindle driver. Description. VCM driver.

M24SR-DISCOVERY. Discovery kit for the M24SR series Dynamic NFC/RFID tag. Features

Scan. This is a sample of the first 15 pages of the Scan chapter.

CoLinkEx JTAG/SWD adapter USER MANUAL

ADC Peripheral in Microcontrollers. Petr Cesak, Jan Fischer, Jaroslav Roztocil

GM69010H DisplayPort, HDMI, and component input receiver Features Applications

PRODUCT INFORMATION LETTER

STEVAL-IHM024V W 3-phase inverter using the L6390 and STGDL6NC60DI for vector control. Features. Applications. Description

In-System Programmability Guidelines

XJTAG DFT Assistant for

Obsolete Product(s) - Obsolete Product(s)

of Boundary Scan techniques.

ST10F273M Errata sheet

XJTAG DFT Assistant for

Description. Table 1. Device summary. Order codes Temperature range [ C] Package Packing. LPS2HBTR -30 to +105 HLGA - 10L

BTW03 DESIGN CONSIDERATIONS IN USING AS A BACKPLANE TEST BUS International Test Conference. Pete Collins

NS8050U MICROWIRE PLUSTM Interface

BSDL Validation: A Case Study

Based on slides/material by. Topic 14. Testing. Testing. Logic Verification. Recommended Reading:

Introduction to JTAG / boundary scan-based testing for 3D integrated systems. (C) GOEPEL Electronics -

SAU510-USB ISO PLUS v.2 JTAG Emulator. User s Guide 2013.

TMS320C6000: Board Design for JTAG

AT18F Series Configurators. Application Note. Stand-alone or In-System Programming Applications for AT18F Series Configurators. 1.

VT5365. Single-chip optical mouse sensor for wireless applications. Features. Applications. Technical specifications. Description.

C-MAX. CMM-9301-V3.1S Bluetooth 4.0 Single Mode HCI Module. Description. 1.1 Features

JTAG Boundary- ScanTesting

STEVAL-ISB008V1. Standalone USB Li-Ion battery charger demonstration board based on the STw4102 and STM32F103C6. Features.

STEVAL-IFN003V1. PMSM FOC motor driver based on the L6230 and STM32F103. Features. Description

GM60028H. DisplayPort transmitter. Features. Applications

Logic Analysis Fundamentals

Chapter 10 Exercise Solutions

STEVAL-IHM021V W, 3-phase inverter based on the L6390 and UltraFASTmesh MOSFET for speed FOC of 3-phase PMSM motor drives. Features.

STEVAL-IHM038V1. BLDC ceiling fan controller based on the STM32 and SLLIMM-nano. Description. Features

Using on-chip Test Pattern Compression for Full Scan SoC Designs

M24LR04E-R, M24LR16E-R, M24LR64E-R Errata sheet

ECE 372 Microcontroller Design

LAX_x Logic Analyzer

Mask Set Errata for Mask 1M07J

Obsolete Product(s) - Obsolete Product(s)

Application Note. Traffic Signal Controller AN-CM-231

Debugging Memory Interfaces using Visual Trigger on Tektronix Oscilloscopes

MP-III Writer User Manual MANUAL REVISION HISTORY Version Date Description V1.0 Mar First Issue SONiX TECHNOLOGY CO., LTD. Page 2 Version 1.0

The use of Time Code within a Broadcast Facility

GM68020H. DisplayPort receiver. Features. Applications

Transcription:

Section 24. Programming and Diagnostics HIGHLIGHTS This section of the manual contains the following topics: 24.1 Introduction... 24-2 24.2 In-Circuit Serial Programming (ICSP )... 24-3 24.3 Enhanced ICSP... 24-6 24.4 JTAG Boundary Scan... 24-7 24.5 Related Application Notes... 24-16 24.6 Revision History... 24-17 24 Programming and Diagnostics 2010 Microchip Technology Inc. DS70608B-page 24-1

dspic33e/pic24e Family Reference Manual Note: This family reference manual section is meant to serve as a complement to device data sheets. Depending on the device variant, this manual section may not apply to all dspic33e/pic24e devices. Please consult the note at the beginning of the Special Features chapter in the current device data sheet to check whether this document supports the device you are using. Device data sheets and family reference manual sections are available for download from the Microchip Worldwide Web site at: http://www.microchip.com 24.1 INTRODUCTION dspic33e/pic24e 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 dspic33e/pic24e devices incorporate three different programming and diagnostic modalities that provide a range of functions useful to the application developer. They are summarized in Table 24-1. Table 24-1: Comparison of dspic33e/pic24e Programming and Diagnostic Features Feature Interface Device Integration Functions In-Circuit Serial Programming (ICSP ) programming method Enhanced ICSP programming method Joint Test Action Group (JTAG) PGCx and PGDx pins PGCx and PGDx pins TDI, TDO, TMS and TCK pins Integrated with device core Hardware integrated with device core; firmware-based control Peripheral to device core; partly integrated with I/O logic Programming, debugging Programming Boundary Scan Testing (BST) diagnostics DS70608B-page 24-2 2010 Microchip Technology Inc.

Section 24. Programming and Diagnostics 24.2 IN-CIRCUIT SERIAL PROGRAMMING (ICSP ) The In-Circuit Serial Programming (ICSP) programming capability is Microchip s proprietary process for microcontroller programming in the target application. Originally introduced for 8-bit PIC16 devices, this method is used for virtually all Microchip microcontrollers. ICSP is the most direct method to program the device, whether the controller is embedded in a system or loaded into a device programmer. 24.2.1 ICSP Interface The ICSP method uses a two-pin communication interface. The Programming Data (PGD) pin 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 (PGC) pin clocks in data and controls the overall process. Most dspic33e/pic24e devices have more than one pair of PGC and PGD pins; these are multiplexed with other I/O or peripheral functions as shown in Figure 24-1. 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 you to incorporate ICSP on the pair of pins least constrained by the circuit design. All PGCx and PGDx pins are functionally tied together and behave identically. 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. The MCLR pin, which is used with PGCx to enter and control the programming process, must also be connected to the programming device. 24 Programming and Diagnostics 2010 Microchip Technology Inc. DS70608B-page 24-3

dspic33e/pic24e Family Reference Manual Figure 24-1: Example of Programming Pin Pairs on a dspic33e Device RPG15 VDD AN29/PWMH3/RPE5 AN30/PWML4/RPIE6 AN31/PWMH4/RPIE7 PWML7/PMPA8/RJ8 PWMH7/PMPA9/RJ9 PMPA10/RJ10 PMPA11/RJ11 AN16/PWML5/RPIC1 AN17/PWMH5/RPIC2 AN18/PWML6/RPIC3 AN19/PWMH6/RPIC4 PMPA12/RJ12 PMPA13/RJ13 C1IND/RPG6 C1INC/RPIG7 C2IND/RPG8 MCLR C2INC/RPIG9 RJ14 RJ15 VSS VDD TMS/RPIA0 AN20/RPIE8 AN21/RPIE9 RK0 RK1 AN5/C1INA/VBUSST/RPIB5 AN4/C1INB/USBOE/RPIB4 AN3/C2INA/RPIB3 AN2/C2INB/RPIB2 PGEC3/AN1/RB1 PGED3/AN0/RB0 VSS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 144 143 142 141 140 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 dspic33ep512mu814 120 119 118 117 116 108 107 106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 115 114 113 AN28/PWML3/RPE4 AN27/PWMH2/RPIE3 AN26/PWML2/CN67/RPE2 VSS RPG13 RPIG12 RPG14 AN25/PWMH1/RPIE1 AN24/PWML1/RPE0 PMPA7/RJ7 PMPA6/RJ6 PMPA5/RJ5 PMPA4/RJ4 AN23/RPIA7 AN22/RPIA6 RPG0 RPG1 RPF1 RPF0 VSS VDD VCAP C3INA/RPD7 C3INB/RPD6 RPD5 RPD4 PMPA3/RJ3 PMPA2/RJ2 PMPA1/RJ1 PMPA0/RJ0 RPID13 RPID12 VDD RPD3 RPD2 VCPCON/RPD1 112 111 110 109 83 82 81 80 79 78 77 76 75 74 73 VSS PGEC1/SOSCO/C3INC/T1CK/RPIC14 PGED1/SOSCI/C3IND/RPIC13 INT0/RPD0 RH15 RH14 RH13 RH12 RPID11 ASCL1/RPID10 ASDA1/RPID9 RTCC/RPID8 RPIA15 RPIA14 PMPCS1/RK11 PMPCS2/RK12 VSS OSCO/CLKO/RC15 OSCIN/RPIC12 VDD TDO/RPIA5 TDI/RPIA4 ASDA2/RPIA3 ASCL2/RPIA2 RH11 RH10 RH9 RH8 DPLUS/RG2 DMINUS/RG3 VUSB VBUS RPF8 RPF2 USBID/RPF3 VSS PGEC2/AN6/RPIB6 PGED2/AN7/RPIB7 VREF-/RA9 VREF+/RA10 AVDD AVSS PMPD0/RH0 PMPD1/RH1 PMPD2/RH2 PMPD3/RH3 AN8/RPIB8 AN9/RPIB9 AN10/CVREF/RPIB10 AN11/RPIB11 VSS VDD PMPRD/RK15 PMPWR/RK14 PMPBE/RK13 TCK/RPIA1 RPF13 RPF12 AN12/RPIB12 AN13/RPIB13 AN14/RPIB14 AN15/RPIB15 VSS VDD PMPD4/RH4 PMPD5/RH5 PMPD6/RH6 PMPD7/RH7 RPID14 RPD15 SDA2/RPF4 SCL2/RPF5 Note: Programming pin pairs are shown in bold type. 24.2.2 ICSP Operation ICSP mode uses a combination of internal hardware and external control to program the target device. Programming data and instructions are provided on the PGD pin. A special set of 4-bit commands, combined with standard dspic33e/pic24e instructions, controls the overall process of writing to the program memory. The PGD pin also returns data to the external programmer in response to queries. The programming process is controlled by manipulating the PGC and MCLR pins. Entry into and exit from ICSP 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 for 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. DS70608B-page 24-4 2010 Microchip Technology Inc.

Section 24. Programming and Diagnostics The internal process is regulated by a state machine built into the dspic33e/pic24e core logic; however, overall control of the process must be provided by the external programming tool. Microchip programming tools, such as the MPLAB PM3 Universal Device Programmer (used with the MPLAB IDE development software), include the necessary hardware and algorithms to manage the programming process for dspic33e/pic24e devices. Users who are interested in a more detailed description, or who are considering designing their own programming interface for a dspic33e/pic24e device, should refer to the dspic33e/pic24e Flash Programming Specification (DS70619). 24.2.3 ICSP and In-Circuit Debugging The ICSP method also provides a hardware channel for in-circuit debugging, which allows external control of software debugging. Using the appropriate hardware interface and software environment, you can force the device to single-step through its code, track the actual content of multiple registers, and set software breakpoints. To use in-circuit debugging, an external system must load a debug executive program into the microcontroller. This task is handled automatically by many debugging tools, such as MPLAB REAL ICE and MPLAB ICD 3. For dspic33e/pic24e devices, the program is loaded into the executive program memory in the configuration memory space. Although memory is implemented and code can be executed from these locations, the executive memory space is not available to the user application during normal operating modes. For details, refer to the dspic33e/pic24e Flash Programming Specification (DS70619). Because of the memory location, use of the debug executive has no impact on the size of the application being examined. The executive memory space allows use of the entire program memory for program code, without needing to reserve space for application debugging. In addition, its use means that the program memory content in normal and debug states is identical, which helps to simplify troubleshooting. Depending on the particular dspic33e/pic24e device, one or more ICSP ports can be used for programming. However, only one of these ICSP ports can be used for in-circuit debugging. Use the following process to select which part to activate for debugging via your MPLAB IDE setup: 1. In MPLAB IDE, select the Configure > Configuration Bits menu to display the Configurations Bits window. 2. In the Configuration Bits window, select the appropriate debug pair setting under the Comm Channel Select Category. Note: For details on the configuration memory space, refer to the dspic33e/pic24e Flash Programming Specification (DS70619). The dspic33e and PIC24E devices contain a new and improved Debug module that expands their debugging capabilities. Some of the new capabilities (provided with MPLAB X IDE in conjunction with MPLAB REAL ICE and MPLAB ICD 3) are: The ability to non-intrusively probe and/or modify internal registers and memory locations at run-time without halting the CPU execution Up to six data sources can be monitored and streamed out to the host computer whenever they are modified without any impact on CPU operation. They can be examined at run-time either via the watch window or plotted graphically (MPLAB REAL ICE only). Application input/output. The ability to exchange application data with the CPU without halting CPU execution and with minimum impact on the CPU. The capability of the user s application to stream out data to the host computer via a 16-word hardware FIFO (MPLAB REAL ICE only) Up to six complex breakpoints that can be set up to monitor address and/or data and events Advanced modes for breakpoints such as: Break on Address Greater Than or Equal to All of these capabilities use the same ICD interface pins (PGC and PGD), which are used for programming. No external components are needed. 24 Programming and Diagnostics 2010 Microchip Technology Inc. DS70608B-page 24-5

dspic33e/pic24e Family Reference Manual 24.3 ENHANCED ICSP The Enhanced ICSP protocol is an extension of the ICSP method. Enhanced ICSP uses the same physical interface as the original, but changes the location and execution of programming control. ICSP mode uses a simple state machine to control each step of the programming process; however, the state machine is controlled by an external programmer. In contrast, Enhanced ICSP uses an on-board bootloader, known as the programming executive, to manage the programming process. While overall device programming is still overseen by an external programmer, the programming executive manages most of the things that must be directly controlled by the programmer in standard ICSP. The programming executive implements its own command set, wider in range than the original ICSP, that can directly erase, program, and verify the microcontroller s program memory. This avoids the need to repeatedly run ICSP command sequences to perform simple tasks. As a result, Enhanced ICSP mode can program or reprogram a device more quickly than ICSP mode. Like the in-circuit debug executive, the programming executive does not reside in the user application program memory space. It is also loaded into the executive program memory. Since the debugger and Enhanced ICSP executives both use this memory space, in-circuit debugging is not available while Enhanced ICSP mode is being used for programming. The programming executive is not preprogrammed into dspic33e/pic24e devices. If you need Enhanced ICSP, you must use standard ICSP to program the executive to the executive memory space. You can set this up directly in your software, or automatically using a compatible Microchip programming system. For additional information on Enhanced ICSP and the programming executive, refer to the dspic33e/pic24e Flash Programming Specification (DS70619). DS70608B-page 24-6 2010 Microchip Technology Inc.

Section 24. Programming and Diagnostics 24.4 JTAG BOUNDARY SCAN As the complexity and density of board designs increase, testing electrical connections between the components on fully-assembled circuit boards poses many challenges. To address these challenges, the Joint Test Action Group (JTAG) developed a method for boundary scan testing that was later standardized as IEEE 1149.1-2001, IEEE Standard Test Access Port and Boundary Scan Architecture. The JTAG boundary scan method adds a shift register stage adjacent to each of the component s I/O pins, which permits signals at the component boundaries to be controlled and observed using a defined set of scan test principles. An external tester or controller provides instructions and reads the results serially. The external device also provides common clock and control signals. Depending on the implementation, access to all test signals is provided through a standardized 4-pin or 5-pin interface. In system level applications, individual JTAG-enabled components are connected through their individual testing interfaces (in addition to their more standard application-specific connections). Devices are connected in a series or daisy-chained fashion, with the test output of one device connected exclusively to the test input of the next device in the chain. Instructions in the JTAG boundary scan protocol allow the testing of any one device in the chain, or any combination of devices, without testing the entire chain. In this method, connections between components, as well as connections at the boundary of the application, can be tested. Figure 24-2 shows a typical application incorporating the JTAG boundary scan interface. In this example, a dspic33e/pic24e device is daisy-chained to a second JTAG-compliant device. The Test Data Input (TDI) line from the external tester supplies data to the Test Data Input (TDI) pin of the first device in the chain (in this case, the DSC). The resulting test data for this two-device chain is provided from the Test Data Output (TDO) pin of the second device to the TDO line of the tester. Figure 24-2: dspic33e/pic24e-based JTAG-Compliant Application Showing Daisy Chaining of Components dspic33e/pic24e-based Application dspic33e/pic24e dspic33e/pic24e (or other JTAG compliant device) JTAG Controller TDI TDO TCK TMS TRST Standard JTAG Connector (optional) TDI TDO TCK TMS TDI TDO TCK TMS 24 Programming and Diagnostics 2010 Microchip Technology Inc. DS70608B-page 24-7

dspic33e/pic24e Family Reference Manual In the dspic33e/pic24e device family, the hardware for the JTAG boundary scan is implemented as a peripheral module (i.e., outside of the CPU core) with additional integrated logic in all I/O ports. The dspic33e/pic24e family implements a 4-pin JTAG interface (see Table 24-2). Table 24-2: JTAG Pin Functions Interface Pin Function Test Clock Input (TCK) Provides the clock for test logic Test Mode Select Input (TMS) Used by the Test Access Port (TAP) to control test operations Test Data Input (TDI) Serial input for test instructions and data Test Data Output (TDO) Serial output for test instructions and data A logical block diagram of the JTAG module is shown in Figure 24-3, and consists of the following key elements: TAP Interface Pins (TDI, TMS, TCK and TDO) TAP Controller Instruction Shift Register and Instruction Register (IR) Data Registers Figure 24-3: JTAG Logical Block Diagram Instruction Shift Register TDO Selector (MUX) TDI TDO TMS TCK TAP Controller Capture-IR Shift-IR Update-IR Capture-DR Shift-DR Update-DR Instruction Register Instruction Decode Data Registers Output Data Sampling Register Bypass Register Device ID Register MCHP Command Shift Register To Internal Logic MCHP Scan Data from Internal Logic MCHP Command Register Boundary Scan Cell Registers Data Selector (MUX) DS70608B-page 24-8 2010 Microchip Technology Inc.

Section 24. Programming and Diagnostics 24.4.1 Test Access Port (TAP) and TAP Controller The Test Access Port (TAP) on the dspic33e/pic24e device family is a general purpose port that provides test access to many built-in support functions and test logic defined in IEEE Standard 1149.1. The TAP controller and the associated boundary scan pins are disabled by programming the JTAG Enable (JTAGEN) bit to 0 in the FICD Configuration register. The TAP controller, by default, is enabled in the bit s unprogrammed state. While enabled, the designated I/O pins become dedicated TAP pins. Use the following process to enable or disable the JTAG port via your MPLAB IDE setup: 1. In the MPLAB IDE click Configure > Configuration Bits menu to display the Configuration Bits window. 2. In the Configuration Bits window, select the Enable/Disable setting under the JTAG Port Enable Category. Note: For information on the FICD register, refer to the dspic33e/pic24e Flash Programming Specification (DS70619). To minimize I/O loss due to JTAG scans, the optional TAP Reset (TRST) input pin, specified in the standard, is not implemented on dspic33e/pic24e devices. For convenience, a soft TAP Reset is included in the TAP controller, using the TMS and TCK pins. To force a port Reset, apply a logic high to the TMS pin for at least 5 rising edges of TCK. Device Resets (including POR) do not automatically result in a TAP Reset. This must be done by the external JTAG controller using the soft TAP Reset. The TAP controller on the dspic33e/pic24e family devices is a synchronous finite state machine that implements the standard 16 states for JTAG scans. Figure 24-4 shows all the module states of the TAP controller. All Boundary Scan Test (BST) instructions and test results are communicated through the TAP via the TDI pin in a serial format, Least Significant bit first. Figure 24-4: TAP Controller Module State Diagram Test-Logic Reset Run-Test/Idle Select-DR-Scan Select-IR-Scan Capture-DR Capture-IR 24 Shift-DR Exit 1-DR Pause-DR Exit 2-DR Shift-IR Exit 1-IR Pause-IR Exit 2-IR Programming and Diagnostics Update-DR Update-IR 2010 Microchip Technology Inc. DS70608B-page 24-9

dspic33e/pic24e Family Reference Manual By manipulating the state of TMS and the clock pulses on TCK, the TAP controller can be moved through all of the defined module states to capture, shift, and update various instruction and/or data registers. Figure 24-4 shows the state changes on TMS as the controller cycles through its state machine. Figure 24-5 shows the timing of TMS and TCK, while transitioning the controller through the appropriate module states for shifting in an instruction. In this example, the sequence demonstrates how a TAP controller reads an instruction. All TAP controller states are entered on the rising edge of the signal on the TCK pin. The TAP controller starts in the Test-Logic Reset state. Since the state of the TAP controller is dependent on the previous instruction, and therefore could be unknown, it is good programing practice to begin in the Test-Logic Reset state. When TMS is asserted low on the next rising edge of TCK, the TAP controller moves into the Run-Test/Idle state. On the next two rising edges of TCK, TMS is high, which moves the TAP controller to the Select-IR-Scan state. On the next two rising edges of TCK, TMS is held low, which moves the TAP controller into the Shift-IR state. An instruction is shifted in to the Instruction Shift register via the TDI on the next four rising edges of TCK. After the TAP controller enters this state, the TDO pin goes from a high-impedance state to active. The controller shifts out the initial state of the Instruction Register (IR) on the TDO pin, on the falling edges of TCK, and continues to shift out the contents of the IR while in the Shift-IR state. The TDO returns to the high-impedance state on the first falling edge of TCK upon exiting the shift state. On the next three rising edges of TCK, the TAP controller exits the Shift-IR state, updates the IR and then moves back to the Run-Test/Idle state. Data, or another instruction, can now be shifted in to the appropriate data or IR. Figure 24-5: TAP State Transitions for Shifting in an Instruction TCK TMS Instruction Data (LSB) TDI TAP State Test_Logic Reset Run_Test Idle Select_DR_Scan Select_IR_Scan Capture_IR Shift_IR Exit_IR Update_IR Run_Test Idle TDO 1 2 3 Note 1: TDO pin is always in a high-impedance state, until the first falling edge of TCK, in either the Shift_IR or Shift_DR states. 2: TDO is no longer high-impedance. The initial state of the Instruction Register (IR) is shifted out on the falling edge of TCK. 3: TDO returns to high-impedance again on the first falling edge of TCK in the Exit_IR state. DS70608B-page 24-10 2010 Microchip Technology Inc.

Section 24. Programming and Diagnostics 24.4.2 JTAG Registers The JTAG module uses a number of registers of various sizes as part of its operation. None of the JTAG registers are located within the device data memory space. They cannot be directly accessed by the user application in normal operating modes. 24.4.2.1 INSTRUCTION SHIFT REGISTER AND INSTRUCTION REGISTER The 4-bit IR allows an instruction to be shifted into the device. The instruction selects the data register to access. The parallel output from the Instruction register is latched to protect from the transient data patterns that occur in its shift register stages as new instruction data is entered. The latched parallel output is controlled, so that it can change state only in the Update-IR and Test-Logic-Reset controller states. A list and description of implemented instructions is provided in 24.4.4 JTAG Instructions. 24.4.2.2 DATA REGISTERS The dspic33e/pic24e device family supports the JTAG data registers listed in Table 24-3. Table 24-3: JTAG Data Registers Register Bypass Register Microchip Command Shift Register JTAG Device ID Register Boundary Scan Register Function Provides a minimum-length serial path for the movement of test data between TDI and TDO. This path can be selected when no other test data register needs to be accessed during a board-level test operation. Use of the Bypass register in a component speeds access to test data registers in other components on a board-level test data path. This 8-bit shift register shifts in Microchip device-specific commands. The parallel output from the shift register is latched to protect from the transient data patterns that occur in its shift register stages as a new command is entered. This 32-bit device IR allows the manufacturer, part number, and variant of a component to be determined. The bit format of the dspic33e/pic24e device consists of an 11-bit manufacturer ID assigned by the IEEE (0x29 for Microchip Technology), device part number, and device revision number. Refer to the dspic33e/pic24e Flash Programming Specification (DS70619) or more information on the bit format. For example, the JTAG ID for a dspic33ep512mu814 device is: Manufacturer ID = 0x29 Part number = 0x1873 Silicon revision = A0 JTAG ID = 0x01873053 Consists of a number of cells combined to form a single shift-register-based path that is connected between TDI and TDO when an appropriate instruction is selected. 24 Programming and Diagnostics 2010 Microchip Technology Inc. DS70608B-page 24-11

dspic33e/pic24e Family Reference Manual 24.4.3 Boundary Scan Register The Boundary Scan Register (BSR) is a large shift register that consists of all the I/O Boundary Scan Cells daisy-chained together, as shown in Figure 24-6. Each I/O pin has one Boundary Scan Cell (BSC). Each BSC contains three BSC registers: an input cell register, an output cell register and a control cell register. When the SAMPLE/PRELOAD or EXTEST instructions are active, the BSR is placed between the TDI and TDO pins, with the TDI pin as the input and the TDO pin as the output. The size of the BSR depends on the number of I/O pins on the device. For example, the dspic33ep512mu814 has 122 I/O pins. Three BSC registers for each of the 122 I/Os yields a Boundary Scan register length of 366 bits. Information on the I/O port pin count for a specific device is found in the specific BSDL files. Note: The Boundary Scan Cell is not used for power supply pins (VDD, VCAP, VSS, AVDD, AVSS). The pins that have the JTAG interconnect function and JTAG control are not part of the scan-chain and are not JTAG testable. Figure 24-6: Daisy-Chained Boundary Scan Cell Registers on a dspic33e Digital Signal Controller BSC with Three Register Cells: Input Cell (I) Control Cell (C) Output Cell (O) I/O Pin O C I I C O I C O I C O I C O O C I dspic33e Internal Logic I C O O C I I C O TAP Controller TDI TMS TCK TDO DS70608B-page 24-12 2010 Microchip Technology Inc.

Section 24. Programming and Diagnostics 24.4.3.1 BOUNDARY SCAN CELL The Boundary Scan Cell (BSC) captures and overrides I/O input or output data values when JTAG is active. The BSC consists of three single-bit capture register cells and two single-bit holding register cells. The capture cells are daisy-chained to capture the port s input, output and control (output-enable) data. The capture cells also pass JTAG data along to the Boundary Scan register. Command signals from the TAP controller determine if the JTAG data is captured, and how and when it is clocked out of the BSC. The first register either captures internal data sent to the output driver, or provides serially scanned-in data for the output driver. The second register captures internal output-enable control from the output driver, and also provides serially-scanned output-enable values. The third register captures the input data from the I/O s input buffer. Figure 24-7 shows a typical BSC and its relationship to the I/O port. Figure 24-7: Boundary Scan Cell and Its Relationship to the I/O Port BSC Logic SDO Pad Logic From or To Device, I/O Circuitry, and/or Logic Core OE IN OUT 0 1 0 1 0 1 D Q D Q D Q 0 D Q D Q 0 1 Port Data Input 0 1 0 1 Data Out Enable Port Data Output Input Buffer Output Buffer Pin 24 SHIFT SDI CAPTURE CLOCK (Capture Registers) UPDATE CLOCK (Update Registers) Global JTAG Signals HIGHZ EXTEST Programming and Diagnostics 2010 Microchip Technology Inc. DS70608B-page 24-13

dspic33e/pic24e Family Reference Manual 24.4.4 JTAG Instructions dspic33e/pic24e devices support the mandatory instruction set specified by IEEE 1149.1, as well as several optional public instructions defined in the specification. These devices also implement Microchip-specific instructions. Table 24-4 describes these mandatory, optional, and Microchip-specific JTAG instructions. Table 24-4: JTAG Instructions JTAG Instruction Description BYPASS (0x0F) SAMPLE/PRELOAD (0x01) EXTEST (0x03) IDCODE (0x02) HIGHZ (0x04) MCHP_SCAN (0x07) MCHP_CMD (0x08) Mandatory JTAG Instructions: Bypasses a device in a test chain. In Bypass mode, a single shift register stage provides a minimum-length serial path between the TDI and TDO pins. Takes snapshots of the component s input and output signals without interfering with the normal operation of the assembled board. The snapshot is taken on the rising edge of TCK in the Capture-DR controller state. The data can be viewed by shifting through the component s TDO output. This instruction also allows the scanning of the BSR without interfering with normal operation of the on-chip system logic. For example, before the EXTEST instruction is selected, data can be loaded onto the latched parallel outputs using PRELOAD. As soon as the EXTEST instruction is transferred to the parallel output of the Instruction register, the preloaded data is driven through the system output pins. This ensures that known data, consistent at the board level, is driven immediately when the EXTEST instruction is entered. Without PRELOAD, indeterminate data would be driven until the first scan sequence had been completed. Allows testing of off-chip circuitry and board level interconnections. Data typically is loaded onto the latched parallel outputs of the Boundary Scan shift register stages by using the PRELOAD instruction before the EXTEST instruction is selected. BSR cells at output pins are used to apply test stimuli. Those at input pins are used to capture test results. Optional JTAG Instructions Selects a 32-bit identification register to be connected for serial access between TDI and TDO in the Shift-DR controller state. This instruction causes the 32-bit device identification word to be shifted out on the TDO pin. Places the component in a state in which all of its system logic outputs are placed in an inactive drive state (e.g., high-impedance). In this state, an in-circuit test system drives the signals onto the connections normally driven by a component output without damaging the component. In the HIGHZ mode, the Bypass register is connected between TDI and TDO in the Shift-DR state. Microchip-specific JTAG Instructions Selects the internal Microchip-specific scan register to be connected for serial access between the TDI and TDO in the Shift-DR controller state. Selects 8-bit Microchip Command shift register to be connected for serial access between the TDI and TDO in the Shift-DR controller state. This shift register supports up to 256 commands. The following command is available for the user; the rest are reserved: JTAG_MCLR (0x01): Performs a device Master Clear Reset while the JTAG interface is active; functionally equivalent to hardware MCLR. The TAP interface itself is not reset. DS70608B-page 24-14 2010 Microchip Technology Inc.

Section 24. Programming and Diagnostics 24.4.5 Boundary Scan Testing Boundary Scan Testing (BST) is the method of controlling and observing the boundary pins of the JTAG-compliant device with software. BST can be used to test connectivity between devices by daisy-chaining JTAG compliant devices to form a single scan chain. Several scan chains can exist on a printed circuit board to form multiple scan chains. These multiple scan chains can then be driven simultaneously to test many components in parallel. Scan chains can contain both JTAG compliant devices and non-jtag compliant devices. A key advantage of BST is that it can be implemented without physical test probes. All that is needed is a 4-wire or 5-wire interface and an appropriate test platform. Since JTAG boundary scan has been available for many years, many software tools exist for testing scan chains without the need for extensive physical probing. The main drawback to BST is that it can only evaluate digital signals and circuit continuity. It cannot measure input or output voltage levels or currents. 24.4.5.1 RELATED JTAG FILES To implement BST, all JTAG test tools require a Boundary Scan Description Language (BSDL) file. BSDL is a subset of VHSIC Hardware Description Language (VHDL), and is described as part of IEEE 1149.1. The device-specific BSDL file describes how the standard is implemented on a particular device and how it operates. The BSDL file for a particular device includes the following: Pinout and package configuration for the particular device Physical location of the TAP pins Device ID register and the device ID Length of the IR Supported BST instructions and their binary codes Length and structure of the Boundary Scan register Boundary scan cell definition Device-specific BSDL files are available at Microchip s web site, www.microchip.com. The name for each BSDL file is the device name and silicon revision. For example, dspic33ep512mu814.bsd is the BSDL file for the dspic33ep512mu814 device. 24 Programming and Diagnostics 2010 Microchip Technology Inc. DS70608B-page 24-15

dspic33e/pic24e Family Reference Manual 24.5 RELATED APPLICATION NOTES This section lists application notes that are related to this section of the manual. These application notes may not be written specifically for the dspic33e/pic24e device family, but the concepts are pertinent and could be used with modification and possible limitations. The current application notes related to Programming and Diagnostics are: Title Application Note # No related application notes at this time. N/A Note: Visit the Microchip web site (www.microchip.com) for additional application notes and code examples for the dspic33e/pic24e family of devices. DS70608B-page 24-16 2010 Microchip Technology Inc.

Section 24. Programming and Diagnostics 24.6 REVISION HISTORY Revision A (August 2009) This is the initial release of the document. Revision B (December 2010) This revision includes the following updates: Added a note at the beginning of the section, which provides information on complementary documentation Updated the dspic33e references in the entire document as dspic33e/pic24e Updated the first paragraph in 24.2.1 ICSP Interface Changed the name of pin 123 to VCAP (see Figure 24-1: Example of Programming Pin Pairs on a dspic33e Device ) Add information on the new and improved Debug module capabilities (see 24.2.3 ICSP and In-Circuit Debugging ) Removed the last sentence of the first paragraph and removed the fifth paragraph in 24.4 JTAG Boundary Scan Updated the description for MCHP_CMD (0x08) in Table 24-4 Removed 24.4.6 JTAG Device Programming Updates to formatting and minor text changes have been incorporated throughout the document 24 Programming and Diagnostics 2010 Microchip Technology Inc. DS70608B-page 24-17

dspic33e/pic24e Family Reference Manual NOTES: DS70608B-page 24-18 2010 Microchip Technology Inc.

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 our products. Attempts to break Microchip s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act. DS70608B24Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTA- TIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer s risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights. Trademarks The Microchip name and logo, the Microchip logo, dspic, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC 32 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, 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. 2010, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. ISBN: 978-1-60932-761-3 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. 2010 Microchip Technology Inc. DS70608B-page 24-19

Worldwide Sales and Service AMERICAS Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://support.microchip.com Web Address: www.microchip.com Atlanta Duluth, GA Tel: 678-957-9614 Fax: 678-957-1455 Boston Westborough, MA Tel: 774-760-0087 Fax: 774-760-0088 Chicago Itasca, IL Tel: 630-285-0071 Fax: 630-285-0075 Cleveland Independence, OH Tel: 216-447-0464 Fax: 216-447-0643 Dallas Addison, TX Tel: 972-818-7423 Fax: 972-818-2924 Detroit Farmington Hills, MI Tel: 248-538-2250 Fax: 248-538-2260 Kokomo Kokomo, IN Tel: 765-864-8360 Fax: 765-864-8387 Los Angeles Mission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608 Santa Clara Santa Clara, CA Tel: 408-961-6444 Fax: 408-961-6445 Toronto Mississauga, Ontario, Canada Tel: 905-673-0699 Fax: 905-673-6509 ASIA/PACIFIC Asia Pacific Office Suites 3707-14, 37th Floor Tower 6, The Gateway Harbour City, Kowloon Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 Australia - Sydney Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 China - Beijing Tel: 86-10-8528-2100 Fax: 86-10-8528-2104 China - Chengdu Tel: 86-28-8665-5511 Fax: 86-28-8665-7889 China - Chongqing Tel: 86-23-8980-9588 Fax: 86-23-8980-9500 China - Hong Kong SAR Tel: 852-2401-1200 Fax: 852-2401-3431 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 China - Shenzhen Tel: 86-755-8203-2660 Fax: 86-755-8203-1760 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049 ASIA/PACIFIC India - Bangalore Tel: 91-80-3090-4444 Fax: 91-80-3090-4123 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 India - Pune Tel: 91-20-2566-1512 Fax: 91-20-2566-1513 Japan - Yokohama Tel: 81-45-471-6166 Fax: 81-45-471-6122 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 Taiwan - Hsin Chu Tel: 886-3-6578-300 Fax: 886-3-6578-370 Taiwan - Kaohsiung Tel: 886-7-213-7830 Fax: 886-7-330-9305 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 EUROPE Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 UK - Wokingham Tel: 44-118-921-5869 Fax: 44-118-921-5820 08/04/10 DS70608B-page 24-20 2010 Microchip Technology Inc.