Electronic – Cannot debug project using “MPLAB X IDE” on “PIC32 Bluetooth Audio Development Kit” with “PICkit 3 In-Circuit Debugger”

mplabxpicpickitxc32

I have "PIC32 Bluetooth Audio Development Kit" (DV320032) board (with on-board PIC32MX470F512L) connected to a PC via "PICkit 3 In-Circuit Debugger" (PG164130). After some experimentation I found out how to blink 3 out of the 5 user LEDs on the board. I use MPLAB XC32 C/C++ toolchain i.e. MPLAB X IDE v3.26 with XC32 v1.40. I created a new C project using the X IDE, did not change any options, only added a little bit of code into the main to blink three LEDs.

I can run project. Meaning it builds the application, loads it into the target, and executes it. LEDs blink happily.

However, when I do debug project, after successful build and programming, I first get pop-up saying that the "Watchdog Timer Enable = On". I accept the options to change the setting. It then continues and the next message I get is:

The target device is not ready for debugging. Please check your
configuration bit settings and program the device before proceeding.
The most common causes for this failure are oscillator and/or PGC/PGD
settings.

I searched for help and found some people suggesting to disable debug i.e. DEBUG = OFF (some people say it makes no difference), I checked and this option in already off.

So my question is: "How can I debug the project?"

Best Answer

The (harmless) watchdog pop-up can be disabled using #pragma config FWDTEN = OFF, typically placed together with other configuration pragmas just before the main function.

My real problem was indeed with PGC/PGD settings (as suggested by the error message). I missed this at first because searching for PGC and PGD yielded no hits. Then, in the schematic, I noticed PGEC2/PGED2 and found ICS_PGx1 in the configuration. Solution turned out to be trivial:

#pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2)

placed in the code just before the main.