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.

MPLAB and debug mode error PK2Error0028

Status
Not open for further replies.

edeca

Active Member
I've just spent 30 minutes wondering why debug mode didn't work on a 16F88. Everything seemed to compile and program fine but I constantly got the error "PK2Error0028: Unable to enter debug mode".

It was all because I had:

Code:
#include "p16f88.inc"

Instead of:

Code:
#include <p16f88.inc>

So this is mainly here for my memory, but perhaps it will help somebody else in the long run.
 
Last edited:
Actually that hasn't helped at all. I'm now getting the same error again. The 16F88 is wired the same way as the 18F1320 I just took off the board. Pull-up resistor and diode to MCLR.

My program is as simple as they get:

Code:
		errorlevel -302		; Disable bank warnings
		#include <p16f88.inc>
		list p=16f88

		__CONFIG	_CONFIG1, _CPD_OFF & _CP_OFF & _DEBUG_ON & _LVP_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _WRT_PROTECT_OFF & _INTRC_IO & _BODEN_OFF

		;cblock 0x20		; Variables
		;	test
		;endc

		org 0
		nop
		goto Start

Start	clrf	STATUS
		clrf	PORTA
		clrf	PORTB

		bsf		STATUS, RP0 	; Bank 1
		clrf	TRISA			; All PORTA output
		clrf  	TRISB			; All PORTB output
	
		; Disable A/D, all ports digital
		clrf 	ANSEL
	
		; Disable comparators
		movlw	0x07
		movwf	CMCON
	
		; Set 4 MHz clock
		;banksel OSCCON 
		bsf		OSCCON, IRCF2
		bsf		OSCCON, IRCF1
		bcf		OSCCON, IRCF0
	
		bcf		STATUS, RP0		; Bank 0
		movlw	0xFF
		movwf 	PORTA

Loop	goto 	Loop

		end

Do I need to do anything special with the Junebug to make ICD work? Programming/verifying is fine even when I'm getting the error.
 
Remove
_MCLR_ON & _PWRTE_ON & _DEBUG_ON

Thanks Bill, another stupid error! Do I need to put them back if compiling for release? Or will changing profiles in MPLAB do that for me.
 
Hm. I still get the error sporadically. Here's the output, which I think is fine except the last error.

Code:
Initializing PICkit 2 version 0.0.3.61
Found PICkit 2 - Operating System Version 2.32.0
Target power detected ( 4.99V)
PIC16F88 found (Rev 0x8)
PICkit 2 Ready

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 (08/03/2009  21:53:46)
PIC16F88 found (Rev 0x8)
Erasing Target
Programming Program Memory (0x0 - 0x13)
Programming Program Memory (0x800 - 0x803)
Verifying Program Memory (0x0 - 0x13)
Verifying Program Memory (0x800 - 0x803)
Programming Debug Executive (0x-F00 - 0xFFF)
Verifying Debug Executive (0xF00 - 0xFFF)
Programming Debug Vector
Verifying Debug Vector
Programming Configuration Memory
Verifying Configuration Memory
Running Target
PK2Error0028:  Unable to enter debug mode
Debug mode entered, DE Version = 0.0.0
PICkit 2 Ready

My program hasn't changed, except your recommended removal which makes config:

Code:
__CONFIG	_CONFIG1, _CPD_OFF & _CP_OFF & _LVP_OFF & _WDT_OFF & _WRT_PROTECT_OFF & _INTRC_IO & _BODEN_OFF

This is driving me nuts now. I thought I'd be able to sit down and write out "my first ASM program" but I haven't got past flashing the status LED because I can't debug. How infuriating :)
 
MPLAB 8.2. I've just switched from the ICD header to the pins along the top of the Junebug and get the same results. I have also tried powering from the Junebug rather than external power.

MPLAB also constantly tells me that the project is out of date, even if I don't change anything. I'm unsure what causes that either.

In any case, I'm not sure my Junebug has ever been right since I had to separate the tracks with a knife! I sit down for a day to play and never seem to get past ICD errors when I start trying hardware instead of simulation.

I'm tempted to pick up a PICkit2 for £30.. if only there weren't so many cheap Chinese knock offs!
 
I've tried your program with both a genuine PK2 and my Junebug. Both give the error with MPLAB 8.20a but you can still single step.
I've modified the program for a 18F1320 and it works fine. Seems like an MPLAB 8.20a bug...
 
Weird. Sorry to sound negative about the Junebug, my frustration got the better of me!

I'll bug it at Microchip if I can find the right place. I need the A/D on the 16F88 or I'd swap it out for another part.
 
I have had this with the PICKIT2 - unplugging the USB and closing down MPBLAB seems to get me back on track. Doesn't really happen that often though.
 
I've tried that a few times. The only thing I haven't tried is another machine, I'll see if I have time tonight to install the software and try it on my laptop.
 
I wonder if it's the new absolute vs relocate mode in 8.20?

PS the 18F1320 has an improved AD vs the 16F88. It doesn't have the comparitors though.
 
Last edited:
An interesting thought. I'll try an older MPLAB tonight and also try both of the modes (I don't remember which I chose). I haven't raised a support ticket yet so I will wait until I've tested.

I'm flying to Canada for a week (hi Bill and anybody else there :D) so wont have much time to play.
 
Bill, a quick look at the Junebug circuit suggests the two 4.7K pull-down resistors are included, so there's no chance I need those?
 
It's the same as the red button PICkit2. Try your program with the 18F1320 and see if the problem goes away. Any reason the A/D in the 18F1320 is not good for your application?
 
Actually I was just thinking I'd try a 16F part as I've never used them. Perhaps I'll stick to the 18F for now, that's not a bad idea.

Thanks for the clarification on the Junebug. I'll target my application at the 18F1320 and perhaps try another project on the 16F88 later.
 
The 18F are so much nicer to use than the 16F and cost about the same. The A/D also includes a programmable acquisition timer so it's really easy to use.

PS set the OSCCON as early as possible to because the debugger will run so much faster...

movlw 0x62 ; 4MHz
movwf OSCCON
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top