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 CCS Technical Support

Can't debug using MPLAB and pickit3

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



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

Can't debug using MPLAB and pickit3
PostPosted: Sun Aug 10, 2014 9:41 am     Reply with quote

Hello,
I am trying to debug a program using MPLAB and pickit3.
This is the code:
Code:

#include <18F4620.h>
#fuses Hs, NOWDT, NOLVP, DEBUG, NOPROTECT
#DEVICE *=16
#use delay(clock=10000000)
#use rs232(BAUD=9600, UART1, errors)

#define BUTT PIN_A4
#define BUTT_PRESSED (!INPUT(BUTT))
#define G_LED PIN_A5
#define R_LED PIN_B5
#define Y_LED PIN_B4

#DEFINE LED_OFF(X) OUTPUT_HIGH(X)
#DEFINE LED_ON(X)  OUTPUT_LOW(X)

#define LCD_ENABLE_PIN  PIN_E2
#define LCD_RS_PIN      PIN_E0
#define LCD_RW_PIN      PIN_E1
#define LCD_DATA4       PIN_D4
#define LCD_DATA5       PIN_D5
#define LCD_DATA6       PIN_D6
#define LCD_DATA7       PIN_D7

//#include <lcd.c>

void *port_b_ponter;

void chip_init(void)
{
   led_off(r_led);
   led_off(y_led);
   led_off(g_led);
   port_b_ponter = getenv ("SFR:PORTB");
   set_tris_b(0x00);                //Problem was actually here
   //lcd_init();
   
}
void main()
{
chip_init();
   while (true)
   {
   *port_b_ponter = 0xFF;
   delay_ms(100);
   *port_b_ponter = 0x00;
   delay_ms(100);
   }
}

When I set pickit3 as debugger, MPLAB says:
Quote:
PK3Err0040: The target device is not ready for debugging.
Please check your configuration bit settings and program
the device before proceeding.

Stepping target failed

I have configured MPLAB so, that
the configuration bits to be set in the code.
_________________
A person who never made a mistake never tried anything new.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 10, 2014 10:15 am     Reply with quote

Go to MPLAB Help. Then go to Pickit 3 help. Then go to Search.
Type this into the search box:
Quote:
reasons

Then click on the article called:
Quote:
Top 10 reasons why you can't debug

Go through the list and see if you're doing everything correctly.
This article is in the help file for both MPLAB 8.xx and MPLAB X.

Another good article in the list (after searching for reasons) is:
Quote:
Requirements for Debugging
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

PostPosted: Sun Aug 10, 2014 11:03 am     Reply with quote

I found it by searching into the forum.
There was posted this:
look 7.3 into
http://ww1.microchip.com/downloads/en/DeviceDoc/51795B.pdf

I verified those options, and none of them is present.
So thank you, But I did this check.

MPLAB says my config bits aren't OK.
_________________
A person who never made a mistake never tried anything new.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 10, 2014 11:19 am     Reply with quote

Quote:
I found it by searching into the forum

That's not the best way to do it. That PDF only lists 10 reasons.
The MPLAB 8.92 help file list 15 reasons why you can't debug.
The MPLAB X 2.15 help file lists 13 reasons. Please read the actual
help file on Pickit 3. It has more reasons.


--------------------
If that doesn't help, then,

What's your CCS compiler version ?

What board are you using ? (If you are using a CCS or Microchip
evaluation board, etc., post the name of the board).

What MPLAB are you using ? (8.xx or MPLAB X), and the version ?

Given that information I will attempt to duplicate the problem.
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

PostPosted: Sun Aug 10, 2014 1:01 pm     Reply with quote

MPLAB IDE v8.89
CCS Compiller 5.015
Dev Board: PIC18F4620 with ENC28J60 module
_________________
A person who never made a mistake never tried anything new.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 10, 2014 2:05 pm     Reply with quote

OK, I got your same problem. All you have to do to fix it is:

1. Put DEBUG in the #fuses.
or
2. Change the drop-down box at the top of MPLAB to Debug (instead of Release).

If you do either one of those, it should fix it.

Make sure you don't have NODEBUG in your #fuses statement.
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

PostPosted: Mon Aug 11, 2014 12:54 am     Reply with quote

Thank PCM programmer for your quick reply.
I did eighter steps.
As you can see in my first post (at the top), the DEBUG fuse has been configured.
The only thing I haven't tried yet, is to replace the chip with new one.
I am still waiting for delivery.
Since the pickit3 programs the chip without any problems, I decided the hardware connections are OK.
I changed the oscillator
I changed the oscillator to internal (check the timing with the oscilloscope). I tried almost anything.
As long as I use MPLAB Simulator I am able to debug.
When I press RUN butt the pickit3 LEDs flash like discotheque for 1-2 secs, and then the target board starts executing the code.

I will try to make a video so you can see the configuration of the MPLAB.
_________________
A person who never made a mistake never tried anything new.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Mon Aug 11, 2014 1:46 am     Reply with quote

The reason everybody keeps repeating the bit about 'MPLAB', is that it _overrides_ whatever the fuse is set to in CCS....
If MPLAB is in 'debug' mode, then the fuse gets set to DEBUG, even if NODEBUG is selected, and vice versa. Hence the fuse setting isn't what matters.

So the critical thing is to ensure that the project is set to compile in DEBUG mode inside MPLAB.
For V8.xxx Project, Build Configuration, Debug.

This normally is a problem the 'other way', with MPLAB setting projects to debug by default, which then won't run if programmed. However there are ways of reversing this, and if your code programs and runs, it suggests your system may be set up this way. So lets 'put this one to bed' first....

Beyond this, I'd suggest doing a re-install of MPLAB. It's possible the ICD debugger component is faulty in the install.
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

PostPosted: Mon Aug 11, 2014 11:02 am     Reply with quote

This is a short video, describing the MPLAB debug medium.
https://www.youtube.com/watch?v=JVsMuhsAcps&feature=youtu.be
I reinstalled the MPLAB as well.
_________________
A person who never made a mistake never tried anything new.
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

PostPosted: Mon Aug 11, 2014 1:06 pm     Reply with quote

I made it. I works now.
In my opinion I was wrong, programming the chip using a pickit3 as a programmer.
I should have programmed the target into debug mode.
Every time I program the new compiled code I choose programmer -> pickit3 and then write.
What is different now is that I program the chip from the Debug drop-down menu instead of a programmer.
It works now.
Thank you!
_________________
A person who never made a mistake never tried anything new.
CARl0S_LEOPOLD0



Joined: 09 Dec 2015
Posts: 2
Location: Mexico

View user's profile Send private message

PostPosted: Fri Oct 28, 2016 4:33 pm     Reply with quote

Hi everybody I found the way for use the pickit3 as debugger without program in asm.

1. You need program your PIC (in this case in CCS). For this step you pickit3 is in programmer mode.
2. Open MPLAB IDE (in my case I have the version 8.2).
3. Connect the pickit3 to PC.
4. In MPLAB IDE select "Debugger" in the bar tool, select "Select tool", select "PICkit 3".
5. The MPLAB IDE will download the software for Debugger pickit3, if you do not have connected your PIC to the pickit3 (see the User's guide PICkit3) in MPLAB IDE show the next error; "PK3Err0040: The target device is not ready for debugging. Please check your".
6. Connect your PIC (or your circuit following the recommendations mentioned in the User's guide PICkit3) to PICkit3.
7. MPLAB IDE show the next message "Voltage caution", just push OK.
8. In MPLAB IDE select "Debugger" in the bar tool, select "Read", select "PICkit 3".
9. In MPLAB IDE select "Debugger" in the bar tool, select "Program", select "PICkit 3".

Now you can to use the debugger buttons for debugging PIC as Step Into, Step Over, animate, and Run.
_________________
Hi
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