Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am trying to run a program on PIC18F4520 using PicKit3 & MPLAB IDE. But I am getting an error: PK3Err0040: The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding.

Whereas when I try to run one of the old program, its running. My new program code which is not running is:

#pragma config OSC = HS,FCMEN = OFF,IESO = OFF              // CONFIG1H
#pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 0                       // CONFIG2L
#pragma config WDT= OFF, WDTPS = 32768                                    // CONFIG2H
#pragma config MCLRE = OFF, LPT1OSC = OFF, PBADEN = ON, CCP2MX = PORTC       //CONFIG3H
#pragma config STVREN = ON, LVP = OFF, XINST = OFF                // CONFIG4L
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF                   // CONFIG5L
#pragma config CPB = OFF, CPD = OFF                                         // CONFIG5H
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF                // CONFIG6L
#pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF                            // CONFIG6H
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF           // CONFIG7L
#pragma config EBTRB = ON                                                  // CONFIG7H


#include "p18f4520.h"
#include "delays.h"


void main(void) 
{ 
TRISA=0b11111111;
TRISB=0b11111111;
TRISC=0b11111111;
TRISD=0b00000000;
TRISE=0x11111111;

while(1)
    {
     Delay10KTCYx(200);
     LATDbits.LATD3=1 ;
     LATDbits.LATD2=1 ;
     LATDbits.LATD1=1 ;
    }

 }

Please let me know where the issue is? is it something to do with bootloader?

share|improve this question
3  
You must have noticed that the formatting of your question didn't look good. Please check this page for information about how you can improve formatting. Users will be more inclined to help if a question is readable. – stevenvh Oct 11 '12 at 8:21

3 Answers

I've had cryptic messages like this when programming and debugging PIC18F with PICkit3, enabling "Power target circuit" option normally solves it. I don't know if it's a PICkit or MPlab oddity, but the option makes the difference between success and failure.

In MPLab, go to Debugger menu, then settings, choose the power tab, and check the power Target Circuit from PICkit3 check box, click apply and OK.

share|improve this answer

Some PICs require a debug header in order to enter debug mode. Make sure the 18F4250 does not require a special debug header.

share|improve this answer

Try adding

#pragma config DEBUG = ON
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.