• AVR Freaks

AnsweredHot!Pickit3 The debugger could not be started.

Author
abhi143
Starting Member
  • Total Posts : 66
  • Reward points : 0
  • Joined: 2018/05/20 09:06:52
  • Location: 0
  • Status: offline
2019/05/25 22:52:52 (permalink)
0

Pickit3 The debugger could not be started.

I have a pickit 3 and I PIC16F877A
IDE : MPLABX
Compiler: XC8

My code is not working as it supposed to do


#include <xc.h>
#pragma config FOSC = XT  // Oscillator Selection bits (XT oscillator)
#pragma config WDTE = OFF  // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON  // Power-up Timer Enable bit (PWRT enabled)
#pragma config BOREN = OFF  // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF  // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF  // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF  // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF  // Flash Program Memory Code Protection bit (Code protection off)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
 
#define _XTAL_FREQ 20000000
 
int main (void)
 
{
    TRISC = 0b00000001; //Timer 1 Clock Input is RC0
    TRISD = 0b00000000;
 
    T1CON = 0b00000011 ;  // 1:1 prescale, OSC disabled, Input Synchronized, External clock on T1CKI(RC0), Timer ON.
 
//Set CCPR1H and CCPR1L (16 bits) to the number of encoder pulses e.g. for 795
    CCPR1H = 0x03;
    CCPR1L = 0x1B;
 
//  Compare mode using CCPR1H and CCPR1L as a 16 bit value
 
  CCP1CON = 00001011;
 
  CCP1IF = 0;
 
  while(1){
 
  if(CCP1IF == 1)  // if the CCP1 Interrupt flag is set
  {
       RD4 = 1;            // set output pulse high
       __delay_ms(40);    // Delay to see ouput ( inbuilt delay)
       RD4 = 0;            // set output pulse low
       CCP1IF = 0;
     CCP1IF = 0;
  }
}
}



When I debug code It gives following error


pickit3

The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding. The most common causes for this failure are oscillator and/or PGC/PGD settings.

*****************************************************
Connection Failed.


debug console

Failed to program the target device
The debugger could not be started.  Terminating debug session.
User program finished


Please suggest me the solution. thank you very much!
#1
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Pickit3 The debugger could not be started. 2019/05/26 00:30:54 (permalink)
+1 (1)
You have selected the "XT" oscillator.
Do you have a crystal connected to the PIC's OSC pins, with appropriate load capacitors?
 

Nearly there...
#2
abhi143
Starting Member
  • Total Posts : 66
  • Reward points : 0
  • Joined: 2018/05/20 09:06:52
  • Location: 0
  • Status: offline
Re: Pickit3 The debugger could not be started. 2019/05/26 03:11:03 (permalink)
0
qhb
You have selected the "XT" oscillator.
Do you have a crystal connected to the PIC's OSC pins, with appropriate load capacitors?
 


Yes 20Mz crystal
#3
Mysil
Super Member
  • Total Posts : 3326
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: Pickit3 The debugger could not be started. 2019/05/26 14:19:36 (permalink) ☼ Best Answerby abhi143 2019/05/27 01:44:26
+2 (2)
Hi,
With 20 MHz crystal, you may need HS oscillator setting in FOSC configuration.
 
    Mysil
#4
Jump to:
© 2019 APG vNext Commercial Version 4.5