In PIC microcontrollers, in-circuit debugging is achieved through the same pins that are used for In-Circuit Serial Programming (ICSP), i.e. ICSPDAT (or PGD), ICSPCLK (or PGC), VPP/MCLR (programming mode voltage), VDD (power supply voltage), and VSS (Ground). This allows manufacturers to integrate ISCP programming and in-circuit debugging features into a single device. During debugging, the ICD device adds an additional block of code (along with the user application) to the target microcontroller’s program memory, which interacts with the debugging application and sends variable values, internal register values and other details to the PC through the same programming cable.
For example, Microchip’s MPLAB ICD2 and ICD3 are both programmer and real-time debugger for selected PIC MCUs and dsPIC DSCs. The functionality of the ICD is controlled by the MPLAB Integrated Development Environment (IDE) application software running on the PC. During debugging all available features of the target microcontroller are accessible interactively through the MPLAB IDE interface. These functions allow you to run the program in single-step mode, insert breakpoints into the program, examine the registers and variables, and modify them if desired.
Although an ICD is an invaluable debugging tool, it does not come at no cost. The two main disadvantages of ICD are: 1) it uses some memory of the target microcontroller, and 2) it occupies a few I/O pins of the target microcontroller to communicate with the PC. Therefore, while debugging, the PGD, PGC, and MCLR pins of the target microcontroller cannot be used for any other purposes.
- See more at:
https://embedded-lab.com/blog/in-circuit-debugging-of-pic-microcontrollers/#sthash.jbyvYZv6.dpuf