8.2.6 Debug Failure Actions

The MPLAB ICD 5 In-Circuit Debugger was unable to perform a debugging operation. Multiple scenarios can result in this error. A few of these are described below.

  1. Device does not have a clock source or the clock source selected in the config bit settings is not functional.
  2. PGD (Data) and PGC (Clock) pins on the device are being used by the application. These pins are required by the debugger and should not be controlled by the application during debug mode.
  3. Many devices contain more than one PGD/PGC pair. The PGD/PGC to be used for debugging is selected using the configuration bit settings. In programming mode any of the PGD/PGC pairs can be used provided it is connected to the debugging tool. For debug mode, the config bit settings must match the correct PGD/PGC pair physically connected to the MCU.
  4. Selecting Run Main Project from MPLAB X IDE when device has not been programmed will generate this message. Use debug mode (
    ) instead.

This information is based the Knowledge Base article Why do I get the following error while trying to debug: "ICD3Err0040: The target device is not ready for debugging"?.