Author Topic: MPLABX: Unable to debug project  (Read 4916 times)

0 Members and 1 Guest are viewing this topic.

Offline Volta500

  • Contributor
  • Posts: 18
  • Country: nl
MPLABX: Unable to debug project
« on: April 09, 2013, 01:27:39 pm »
Hello All,

I am trying to get the debugger working on a simple test program but not having much luck.  :--
When I program it directly it works fine.
Is there some config bit I'm missing or some other setting screwed?

I have also noticed that MPLAB X says that "The requested operation cannot continue with the following configuration bit setting(s):
Flash Program Memory Code Protection bit = All program memory code-protected.
Would you like MPLAB to change the config setting(s) and continue? "
While in my code the CP bit is OFF. If I continue I get the error Failed to program device.

Compiler: Microchip MPLAB XC8 C Compiler V1.12
Chip: PIC16F877A
Programmer: PICKit 3
OS: Windows 7

Code: [Select]
#include <xc.h>       // Main PIC header file
#include <stdio.h>    // Standwerererdard IO
#include <stdlib.h>   // Standard utility functions
#include <stdint.h>   // Contains standard int definitions
#include <stdbool.h>  // Contains standard Boolean definitions
#include "bk300.h"    // BK300 specific functions and definitions

#pragma config FOSC = HS        // Oscillator Selection bits (HS 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)

void main (void){

    printf("Blinking LED 1! \n\r");
    while (1){
        setLed(1, 1);
        setLed(1, 0);

The bk300 header just contains some initialization routines, defines and some functions like setLed(). I doubt it has anything to do with the problem but if you need the content of the file just ask.

Thank you

Offline TheDirty

  • Frequent Contributor
  • **
  • Posts: 440
  • Country: ca
Re: MPLABX: Unable to debug project
« Reply #1 on: April 09, 2013, 03:36:10 pm »
Just a guess.
I'm pretty new to PIC's and XC8, but I don't recognize your config bit setting, so I'm assuming it's for the old compiler and possible does not work anymore?

The config bit setting I use in XC8 is:

If you go to Window -> PIC Memory Views -> Configuration Bits there's a little utility there that can help you create the correct compiler directive specific to your processor.
Mark Higgins

Offline Ax_6

  • Contributor
  • Posts: 15
  • Country: it
Re: MPLABX: Unable to debug project
« Reply #2 on: April 09, 2013, 04:15:45 pm »
Try just to delete the last 3 voices: cp, wrt, cpd and let the compiler use the default ones, it could work, also i don't think that there is any problem in the way you wrote the config bit settings (I don't know if I'm using the same version of xc8 as your but I use to write configs as that).
« Last Edit: April 09, 2013, 04:17:38 pm by Ax_6 »

Offline Volta500

  • Contributor
  • Posts: 18
  • Country: nl
Re: MPLABX: Unable to debug project
« Reply #3 on: April 09, 2013, 05:33:25 pm »
This is the preferred way of writing config bit settings, but xc8 still has legacy support for __CONFIG() but it is deprecated.

DERP- The removal of the last thee config settings solved the issue! Does anyone know why this would give a problem?
Well, at least it it solved. The debugger finally works, although it is quite slow, it is better than nothing. Thank you!

Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo