View previous topic :: View next topic |
Author |
Message |
VanHauser
Joined: 03 Oct 2005 Posts: 88 Location: Ploiesti, Romania
|
Cannot debug PIC24F16KA102: MPLab + CCS compiler + Pickit3 |
Posted: Tue Mar 20, 2012 8:36 am |
|
|
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
|
|
Posted: Thu Mar 22, 2012 12:48 pm |
|
|
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
|
|
Posted: Fri Mar 23, 2012 10:52 am |
|
|
Of course. |
|
|
reash
Joined: 17 Sep 2007 Posts: 8
|
|
Posted: Fri Mar 23, 2012 10:56 am |
|
|
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
|
|
Posted: Fri Mar 23, 2012 5:53 pm |
|
|
Tried that, but same result. |
|
|
VanHauser
Joined: 03 Oct 2005 Posts: 88 Location: Ploiesti, Romania
|
|
Posted: Thu Mar 29, 2012 8:10 am |
|
|
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
|
|
Posted: Thu Mar 29, 2012 8:13 am |
|
|
Glad you got it resolved! |
|
|
|