2020/11/01 07:35:58
Albert Hall
I have done many 8 bit PIC projects but this my first excursion into 16 bit PICs.
I have a very basic program created by MCC and 'make and program device main project' works OK.
However, I cannot program for debugging.  I get 'The target device is not ready for debugging'
This happens with either internal oscillator or a 4MHz crystal.
 
So how do I fix this?
 
MPLABX V5.40.
XC16 V1.60
 
2020/11/01 07:59:29
NorthGuy
These PICs have several PGC/PGD pairs. You can use any for programming. You also can use any for debugging, but there are config bits (FICD.ICS) which specify the pair you're using for debugging. You need to make sure that the config bits specify the pair you use, not any other pair.
2020/11/01 11:23:35
Albert Hall
#pragma config ICS = PGD1    //ICD Communication Channel Select bits->Communicate on PGEC1 and PGED1
I am using pins 21/22 PGED1/PGEC1 for the PICKIT.
And note that I can program it, just not debug it.
2020/11/01 11:52:33
dan1138
Albert Hall
#pragma config ICS = PGD1    //ICD Communication Channel Select bits->Communicate on PGEC1 and PGED1
I am using pins 21/22 PGED1/PGEC1 for the PICKIT.
And note that I can program it, just not debug it.

NorthGuy's suggestion is that you do not know what you think you know.
 
What we do know is:
  1. Your PICkit is connected correctly to one of three pairs of pins that allow the ICD to program your device.
  2. That the pair may not be PGC1/PGD1 because debug would be working if it was.
So try changing the pragma to select one of the other pairs of PGC/PGD pins for debug.
 
<EDIT>
 
After looking at the data sheet (go figure) pins 21/22 are PGC3/PGD3.

 
So use: #pragma config ICS = PGD3    //ICD Communication Channel Select bits->Communicate on PGEC3 and PGED3

Attached Image(s)

2020/11/01 12:03:07
BroadwellConsultingInc
What does your reset circuit look like?  Are you using just a pull up or did you add additional capacitance?
 
2020/11/01 12:11:31
Albert Hall
The only things connected are the PICKIT4, 4MHz XTAL and 2x 33pF, 10uF ceramic on VCAP and 100nF across the supply (all VSS and VDD linked together).
2020/11/01 12:24:23
Albert Hall
"NorthGuy's suggestion is that you do not know what you think you know."
Nothing new there then!
 
I have it working.  Selecting PGEC3/PGED3 for ICD allows programming and debugging.
The pinout I have for this chip shows pins 20/21 as PGEC1/PGED1 but hey-ho all is well now.
 
Thanks guys grin: grin
 
2020/11/01 13:31:13
NorthGuy
Albert Hall
The pinout I have for this chip shows pins 20/21 as PGEC1/PGED1 but hey-ho all is well now.



Unlike 8-bit PICs, dsPIC33s do not have a fixed pinout for programming pins. There are many possible pinouts and the pairs may be numbered differently.
© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account