CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Cannot debug PIC24F16KA102: MPLab + CCS compiler + Pickit3

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
VanHauser



Joined: 03 Oct 2005
Posts: 88
Location: Ploiesti, Romania

View user's profile Send private message

Cannot debug PIC24F16KA102: MPLab + CCS compiler + Pickit3
PostPosted: Tue Mar 20, 2012 8:36 am     Reply with quote

Hello,

I am having trouble debugging a PIC24F16KA102 with the PicKit3.

I am using the following configuration:
- MPLab IDE 8.84
- CCS C Compiler 4.128
- Microchip XLP 16 bit demo board with PIC24F16KA102
- PICKit3

I use a simple program that blinks the two leds on the demo board. I can progam the target successfully with the PICKit3 as programmer, but I cannot debug when I select the PICKit3 as Debugger. It does program the target, but when I click Run, it throws an error:

"PK3Err0040: The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding."

My test code is below:

Code:
#include <24F16KA102.h>   
#device ICD=TRUE   
#FUSES DEBUG
#FUSES ICSP3                  //ICD uses PGC3/PGD3 pins
#FUSES XT                     //Crystal osc <= 3mhz to 10 mhz for PCD   
#FUSES PR_PLL                 //Primary Oscillator with PLL
#FUSES NOBROWNOUT             //No brownout reset
#FUSES NOCKSFSM             
#FUSES NOWRTB
#FUSES NOPUT
#FUSES NOWDT
#FUSES NODSWDT
#FUSES NOPROTECT
#use delay(clock=32000000)
 
void main()
{
 output_bit(PIN_B8,1);
 output_bit(PIN_B15,0);   
 for(;;)
 {
  output_toggle(PIN_B8);
  output_toggle(PIN_B15);
  delay_ms(500);
 }



Build result:

Code:
Executing: "C:\Program Files (x86)\PICC\Ccsc.exe" +FD "main.c" #__DEBUG=1 +ICD +DF +LN  +T +A +M -Z +Y=9 +EA #__PIC24F16KA102__=TRUE
      Memory usage:   ROM=5%      RAM=9% - 9%
      0 Errors,  0 Warnings.
Loaded D:\_projects\test_led\main.cof.
BUILD SUCCEEDED: Tue Mar 20 16:14:43 2012
reash



Joined: 17 Sep 2007
Posts: 8

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 12:48 pm     Reply with quote

Did you try programming your device from the Debugger menu, instead of the Programmer menu?
VanHauser



Joined: 03 Oct 2005
Posts: 88
Location: Ploiesti, Romania

View user's profile Send private message

PostPosted: Fri Mar 23, 2012 10:52 am     Reply with quote

Of course.
reash



Joined: 17 Sep 2007
Posts: 8

View user's profile Send private message

PostPosted: Fri Mar 23, 2012 10:56 am     Reply with quote

I'd try dropping the "#device ICD=TRUE" and only use the "Build Configuration" as "Debug" in the "Project" menu in MPLAB.
VanHauser



Joined: 03 Oct 2005
Posts: 88
Location: Ploiesti, Romania

View user's profile Send private message

PostPosted: Fri Mar 23, 2012 5:53 pm     Reply with quote

Tried that, but same result.
VanHauser



Joined: 03 Oct 2005
Posts: 88
Location: Ploiesti, Romania

View user's profile Send private message

PostPosted: Thu Mar 29, 2012 8:10 am     Reply with quote

Problem solved.

As I have noticed in the .LST file, CCS compiler forces some fuses if Debug is selected in the Release/Debug dropdown menu in Mplab, or if the statement #device ICD=TRUE exists in the source code. It forces the use of PGD1/PGC1 pins instead of PGD3/PGC3, which are wired for the Microchip XLP 16 bit demo board.

Problem solved by building in Release mode, with no #device ICD=TRUE statement.

Test code is below.
Thanks for your help everybody...

Code:

#include <24F16KA102.h>
#FUSES DEBUG
#FUSES ICSP3                  //ICD uses PGC3/PGD3 pins
#FUSES XT                     //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES PR_PLL                 //Primary Oscillator with PLL
#FUSES CKSFSM                 //Clock Switching is enabled, fail Safe clock monitor is enabled

#use delay(clock=32000000)
void main()
{
 output_bit(PIN_B8,1);
 output_bit(PIN_B15,0);
 for(;;)
 {
  output_toggle(PIN_B8);
  output_toggle(PIN_B15);
  delay_ms(500);
 }
}
reash



Joined: 17 Sep 2007
Posts: 8

View user's profile Send private message

PostPosted: Thu Mar 29, 2012 8:13 am     Reply with quote

Glad you got it resolved!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group