2
\$\begingroup\$

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?"

\$\endgroup\$
5
  • \$\begingroup\$ You may have to turn off the watchdog timer. With it running, it will expire in a fraction of a second, causing the PIC32 to restart, cancelling debug. That's what the pop-up is implying. \$\endgroup\$
    – rdtsc
    Commented Apr 19, 2016 at 12:08
  • \$\begingroup\$ @rdtsc Thanks. The pop-up says that it will disable the watchdog for the entire session. However, I will experiment further... \$\endgroup\$ Commented Apr 19, 2016 at 12:24
  • \$\begingroup\$ PS: I disabled the watchdog. Pop-up went away. I still get the "not ready for debugging" message. \$\endgroup\$ Commented Apr 19, 2016 at 12:44
  • \$\begingroup\$ Is anything using the MCLR, PGD, and/or PGC lines, such as an LED output? Those pins should be considered "dedicated" to debug and not used for anything else. Code or external signals manipulating them can interfere. As can choosing an incorrect powering method in the debugger settings, such as "do not power Vdd of the device" and having the device's own power turned off. (The debugger has the ability to power the target device - with limitations.) Be sure to have the datasheet handy - good idea to print it. \$\endgroup\$
    – rdtsc
    Commented Apr 19, 2016 at 13:14
  • \$\begingroup\$ I found the problem and will post answer later on. \$\endgroup\$ Commented Apr 20, 2016 at 14:01

1 Answer 1

4
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ +1. Incorrect debug port settings in your config registers does exactly what you've noticed - you can program the part just fine but cannot debug it. \$\endgroup\$ Commented Apr 21, 2016 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.