Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problems with debugging of Pickit 2

Status
Not open for further replies.

kyru27

New Member
I've a problem when trying to get into debugging a circuit with Pickit 2:

I mean if I compile it with it, first it compiles right and when I try to run it I get a dialog box that says "he local copy of program memory has been changed since the last program operation. Should PICkit 2 program the target (fix) before proceeding?"

If I press no it fails with "cannot enter into debug mode".

If I press yes I get:

PK2Error0027: Failed verify (Address = 0x0 - Expected Value 0xE06 - Value Read 0xF0FC)

I read my PIC18F4620 with Pickit2 and at 0x00 there's 0xE06 for real so I wonder where it can be reading that value (in fact, there's no F0FC anywherere on my program), unless it's not directly from the PIC.

ICSP wires are correctly wired and voltage is right also (checked with a polimeter).





If nobody knows about this I'd like to know if there's some way to do the debugging with the PIC connected to the Pickit2 itself (I mean with the PIC inserted into the socket that is in Pickit 2 not the protoboard, PCB etc) as it seems so , if I run the program with it inserted into it I get:


Initializing PICkit 2 version 0.0.3.63
Found PICkit 2 - Operating System Version 2.32.0
Target power not detected - Powering from PICkit 2 ( 5.00V)
PIC18F4620 found (Rev 0x7)
PICkit 2 Ready

Resetting
PKWarn0006: The local copy of program memory has been changed since the last program operation. Should PICkit 2 program the target (fix) before proceeding?
Programming Target (05/05/2012 16:18:38)
PIC18F4620 found (Rev 0x7)
Erasing Target
Programming Program Memory (0x0 - 0x7F)
Verifying Program Memory (0x0 - 0x7F)
Programming Debug Executive (0x-FDC0 - 0xFFFF)
Verifying Debug Executive (0xFDC0 - 0xFFFF)
Programming Debug Vector
Verifying Debug Vector
Programming Configuration Memory
Verifying Configuration Memory
Running Target
PK2Error0028: Unable to enter debug mode
PICkit 2 Ready

The PIC isn't connected to the circuit so it obviously cannot enter debug mode, but at least in this way there's no error in reading the PIC

Regards.
 
Hi,

The PK2 and 4520/4620 debug in circuit with no problems, have it in front of me now, would have suggested you send your code over, but I only use assembler, assume you are using C and I don't have any C compilers loaded.

Assume you can program the chip in circuit OK ?

Has your program code left Mclre, RB6 and RB7 free for the degugger ?

Has your hardware got anything else on these pins ? - Assume Mclre has been wired as shown in the PK2 user guide ?

PS - notice in that screenshot that Debugger reserves itself a bit of high order memory, you must ensure your own code leaves it free.
 
Last edited:
What version of MPLAB are you currently running?

How are you setting up your configuration word?
 
Problem was I was using RA0 and RA1, and I think it's said this way in Pickit 2 User's Guide (https://www.electro-tech-online.com/custompdfs/2012/05/51553e.pdf).

Thanks.

Hi,

It shows the way the Pk2 should be connected to Pic in ciruit, the chip shown was just an example.

For the 4620 Mclre is pin1, PGD is pin40 RB7 and PGC is pin RB6.

Think you should also check what pins you have connected for Vdd and VSS

Once you have those correct you first want to prove the Programmer part works properly before you attempt the debugger.

You use the Mplab ,Programmer menu for this, not the Debugger menu.




Anyway I now have another problem to be able to debug you have first to program the ICSP header by Debugger-> Program and I get the error unable to enter debug mode. No more information given.

Once you have proven you can program the chip ok then you can try the debugger.

First in the Programmer menu select NONE.

Then in the Debugger menu select the PK2.

Then select RUN or STEP INTO

It will say project out of date so let it compile it again, it should then automatically progam in the Debugger version and start running - as simple as that.

While the Pk2 is robust if you have applied the connections to RA3 as Mclre you might have blown that port if it tried to apply its +12v to it, could possible have blown the whole chip


You also need to answer Johns points about the important Config settings and also to make sure you are using a fairly recent version of MPlab .
 
Last edited:
The error is getting really weird...

I mean, I have been able to enter debug mode perfectly once when, without having changed anything, some moments ago it gave the same error, after that when I compiled again MPLAB started to display a message about a bit that was set that would may make the code not to run properly,wich happened, and after that I haven't been able to enter debug mode again. But that means no problem with Config settings and that it should be working right, also MPlab version is pretty recent (8.83).

I guess Pickit2 is hardly reading right the voltages it is giving to the pins when I try to enter debug mode. In fact when I do troubleshooting in Pickit 2 Programmer it does things like reading 0,0 V or short or 4.7 for Vdd when there are 4.7 all the time, also It reads 4.4 V, 9.2 V or 12 when all the time there are 12 V.

Any other idea of what might be happening?

Thanks a lot.
 
Last edited:
Hi,

Sounds like you have a lot of problems.

First you have three methods of using the PK2, MpLab Programmer, MPlab Debugger and PK2 V2.61 - thing to ensure is that they are all off before you start the one you want , having another running will give things like error 0027 /0028.

Your Pk2 readings look bad, I assume they are with the pic in a circuit ?
Are you applying power directly to that circuit or are you letting the Pk2 try and drive it ? - if so it might be too much for the Pk2 to supply, its limited to about 25ma.

Is your Pk2 connected to a laptop, at 4.7v for VDD that sounds a bit on the low side, its often recommended a seperately powered usb hub be used if the laptops usb voltage is low.


Either way the thing to do is put the 4620 into a socket on its own with just the 5 conenctions to it from the PK2.
Keep those wires less than 6" long.

Then test the voltages with V2.61 diagnostics, recalibrate if needed.

Then try doing a simple programming operation, if ok then try debugger it will run so far before it stops looking for an input signal ec.
 
You still have not told us yet what compiler you're using....?

I mean, I have been able to enter debug mode perfectly once when, without having changed anything, some moments ago it gave the same error, after that when I compiled again MPLAB started to display a message about a bit that was set that would may make the code not to run properly,wich happened, and after that I haven't been able to enter debug mode again.

What bit was it complaining about?
 
Last edited:
I'm using MCC18.

It was complaining about the CPU mode configuration bit like this:

"The exten ded cpu mode configuration bit is enabled, but the program that was loaded was not build using extended CPU instructions. Therefore, your code may not work properly."

Indeed, it didn't work properly.

Anyway that happened after running right for its only time, and I think all the problem would just be to disable that bit, to make it run properly.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top