View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Dec 03, 2024 2:54 am |
|
|
I don't know what you are doing, but I just built a demo project with your
chip, and it merrily compiled:
Code: |
#define __USB_PIC_PERIF__ 1
#include <24FJ256GB206.h>
#build(stack=1024) //With USB, you will need an expanded stack
#device icd=2
#use delay(clock=32MHz,crystal=20000000, USB_FULL)
#FUSES NOWDT //No Watch Dog Timer
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES SOSC_DIG
#include <stdio.h> //These should always be after fuses and clock
#include <math.h>
#include <stdlib.h>
#define USB_CONFIG_BUS_POWER 500
#define USB_CONNECTION_SENSE_PIN PIN_A1
//Connection sense, is _required_ unless the device is USB powered.
#include <usb_cdc.h>
//Then a suitable main
|
Get into your head, there is no fuse on these chips to specify which pins
are used for ICSP. The selection of this is automatic. You can use any of
the three pairs. MCLR is held high and a special unlock sequence is
clocked into the chip. The pin pair being used remains selected till the
chip exits the programming sequence. There is no ICSP selection.
The fuses only specify which of the three pairs available is shared with
the debug functions. These can be located onto any one of the three
pairs. |
|
|
reelthymes
Joined: 26 Jul 2024 Posts: 21
|
|
Posted: Tue Dec 03, 2024 7:09 am |
|
|
Yes, as I said the ICSP is fine, I'm not worried about that.
And I have no issues compiling or even programming the part, the issue is with debugging.
For some reason, whenever I attempt to to step through the code in debug mode, I get that original error:
Quote: | PK3Err0040: The target device is not ready for debugging.
Please check your configuration bit settings and program
the device before proceeding. |
I don't know what else to do. I told the compiler to set #device icd=2, as those are the pins on the MCU that my programmer/debugger are connected to. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Dec 03, 2024 7:38 am |
|
|
You need to tell the compiler to compile for DEBUG. This is separate from
selecting the pins.
What environment are you working in?.
In the CCS IDE, if you select ICD=2 as I show, then it will default to
setting the DEBUG fuse. |
|
|
reelthymes
Joined: 26 Jul 2024 Posts: 21
|
|
Posted: Tue Dec 03, 2024 7:48 am |
|
|
Ttelmah wrote: | You need to tell the compiler to compile for DEBUG. This is separate from
selecting the pins.
What environment are you working in?.
In the CCS IDE, if you select ICD=2 as I show, then it will default to
setting the DEBUG fuse. |
I am using MPLAB v8.92. I already added the line:
#device icd=2
So you're saying that I need to explicitly set the DEBUG fuse in addition to that line? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Dec 03, 2024 8:29 am |
|
|
just copy/paste/compile the code Mr. T posted 2-3 posts above, report back what happens. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Dec 03, 2024 8:30 am |
|
|
Yes, Yes, Yes.
MPLAB, determines the compile line. Project, Build Configuration. Select
Debug, and the project will be built to debug. Select Release and it will
be compiled with debug disabled. |
|
|
reelthymes
Joined: 26 Jul 2024 Posts: 21
|
|
Posted: Tue Dec 03, 2024 8:39 am |
|
|
Build configuration has been set to Debug from the beginning.
I tried using the code example you gave above and I'm seeing the same error. When I try to step through the code, MPLAB launches a pop-up with the title "target out of date" and the message Quote: | "MPLAB's memory has changed since the last program, operation, would you like to continue." |
If I select yes, it generates the original error message that the target is not ready for debug.
Just to be clear on the steps I'm carrying out:
1) compile the project
2) select my PicKit3 as the programmer in MPLAB and program the target (it always says program/verification successful)
3) select PicKit3 as my debugger and attempt to run or step through code |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Dec 03, 2024 8:58 am |
|
|
You don't normally program separately. You select DEBUG, RUN, which then
actually copies the code into the chip, with the debug executive added.
I think you are loading the code, but not this. |
|
|
reelthymes
Joined: 26 Jul 2024 Posts: 21
|
|
Posted: Tue Dec 03, 2024 9:00 am |
|
|
Following the suggestion of a Microchip thread, I did the following and now I'm able to step through the code.
Select Debugger > Settings > Select 'program after successful build"
After enabling that option on my PicKit3, it now allows me to step through the code using the above sample program from Ttelmah.
It also works with my original program. Thank you for the help!
I gained some valuable knowledge about configuration bits and other settings through this exchange. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Dec 03, 2024 12:25 pm |
|
|
Well done.
That isn't an option on most of the debuggers. By default most have this
automatically enabled. Explains the problem.... |
|
|
|