I owned a brand new pickit 4, and I'm trying to get a debug session working. This is what I did:

1. Cut reset pin from the USB-UART programmer. There is a Reset EN pad that can be cutted off to isolate the USB-UART programmer and only use the reset pin from headers. Where is the reset pad

2.Connect pickit 4 to Arduino Mega board. I connected it according the following table with the JTAG pins of the board. Also I connected reset pin, VCC and GND pins. enter image description here enter image description here

3. I did a new project in MPLAB X IDE v5.50, just a new main.c with classic blink led program.

#define F_CPU 16000000UL 
#include <xc.h>
#include <util/delay.h>

int main(void) {
    DDRB = 0x00;
        PORTB |= (0x80);
        PORTB &= ~(0x80);
    return 0;

4. Connect pickit 4 to PC and power up Mega board. With this I had a beautiful cyan light on the pickit4.

5. Read and set configurations bits. Just going into Production>Set Configuration Bits I was able to read them and set them like this: °According to this forum Arduino board has this SUT_CKSEL fuses enter image description here

After all this, I'm able to program the device with the button "Make and Program Device Main Project".

First Issue: The program doesn't work, I mean the led is not blinking... I'm really sure this is a fuse issue, Which fuse is wrong?

Second Issue: Unable to begin debugging session. I've set OCDEN, JTAGEN and SPIEN bits and I got this:

Connecting to  MPLAB PICkit 4...

Currently loaded versions:
Application version............1.13.236
Boot version...................01.00.00
Tool pack version .............1.9.1163
Target voltage detected

Calculating memory ranges for operation...

Configuration memory will not be programmed because no configuration bits settings have been defined in your code. 
To program configuration memory, either define the settings in your code or use the Program Configuration Bits button on the configuration memory window.


The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0xff

Unable to attach to target, OCDEN config bit is not set

If I clear OCDEN fuse I got the same. I'm actually very surprised that I can flash the program, read/write fuses but I can't start debug session.

Also, I've tried with Microchip studio, with no luck. Any ideas?

Thanks in advance!


1 Answer 1


When connecting the debugger make sure the power supply you're using to power the Mega has stable voltage. That was the problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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