# [SOLVED]How to use pickit 3 as a debugger

Status
Not open for further replies.

#### Arrowspace

##### Banned
I am trying to use PICKIT-3 as a debugger , but showing error

#### milan.rajik

##### Banned
Install PICKit3 Programming software. Open it after connecting PICKit3 to PC. In Tools menu choose MPLAB mode. Close it. Open MPLAB and use it for debugging. IN MPLAB compile for DEBUG. Also in the MPLAB settings click PICKIt3 but not the Serial number.

- - - Updated - - -

I think if you set config settings like

Code:
#pragma config DEBUG = ON
it is not considered instead MPLAB and MPLAB X uses the IDE to set the DEBUG ON or OFF that is if you compile the code for DEBUG and not RELEASE then MPLAB or MPLAB X will set the proper DEBUG config bits. MCLR should be ON. Set the config bits properly and try to debug.

#### Aussie Susan

What device are you using? Also, what compiler and IDE (I have assume MPLAB(x) and one of the Microchip free compilers)?
There are a number of reasons why you can get that error message.
Milan has mentioned one of them: namely that you need to compile the code for "DEBUG" (and not "release") mode. However DO NOT follow his advice about setting the DEBUG config item - leave that completely out of your config settings as it is automatically added when necessary by the MPLAB(x) IDE. (The config bit is documented in the data sheet for most of not all Microchip devices but a lot of people have spent many wasted hours trying to work out what is wrong because they have tried to use this option.)
If you have managed to use the PicKit3 to program the MCU then you can assume that the basic connection is correct between the PicKit3 and the MCU.
The error message also comes up when the oscillator is not set correctly.
Also, if the device has various programming pairs of pins, then you can program the device using any of them BUT you must specify (in the CONFIG section) which pair you will use for debugging.
The way it works is this: when you compile your code for 'release', the IDE will generate code that will operate in the MCU stand-alone; it will start as power on and run.
When you select "debug' mode in the IDE, a couple fo things change that you don;t really see. For a start the linker will include a bit of code (often referred to as the debug kernel) into your code and this is the code that is run as the device powers up.
The debug kernel runs as ordinary code within the MCU which means that the device must have an oscillator that runs at power up. (It does not matter what that oscillator is, as long as it is running and the CPU can execute instructions.) The debug kernel also uses the debug pin pair (if appropriate) to try to communicate with the debugger software (normally in your PC). It will hang until it can communicate which means that your device looks like it is not doing anything if no communication link can be established.
Within the IDE on your PC, there is a similar set of actions. In 'release' mode, the IDE will simply raise the \MCLR\ line after programming and your device will start operating.
However in 'debug' mode, after programming the debugger will try to establish its part of the communication to the debug kernel in the device. The message you are seeing is what you get when that communication link cannot be established after a short period of time.
Susan

Status
Not open for further replies.