MCU: Pic16F886
Programmer: PICkit4
IDE: MPLAB X IDE v5.40
Assembler: pic-as v2.30 (xc8)
Circuit:
A LED with 270 ohm resistor on RA0.
3,3k ohm resistor pullup resistor on MCLRE.
Vdd on pin 20.
Vss on pin 19.
This is the test code I want to debug and step through instruction by instruction:
PROCESSOR 16F886
PAGEWIDTH 132
RADIX DEC
#include <xc.inc>
config DEBUG = ON, LVP = OFF, FCMEN = OFF, IESO = OFF, BOREN = OFF
config CPD = OFF, CP = OFF, MCLRE = OFF, PWRTE = OFF, WDTE = OFF
config FOSC = INTRC_NOCLKOUT, LVP = OFF, BOR4V = BOR40V, WRT = OFF
PSECT StartCode,class=CODE,delta=2
global Start
Start:
movlw 11000000B ;set option register
movwf OPTION_REG
movlw 00100000B ;set the status register (select bank 1)
movwf STATUS
movlw 11111110B ;everything to input except for RA0
movwf TRISA
movlw 00000000B ;set the status register (select bank 0)
movwf STATUS
bcf PORTA, 0 ;clear bit zero in PORTA register
sleep
END Start
When I run the project the code works as expected.
But when I set a breakpoint and hit "Debug Main Project" I get the error: Reception on endpoint 129 failed (err = -10121)
Or it stays in the "build, load" state for minutes until I quit the process if I play around with config settings.
The PIC16886 has an "in-circuit debugger (on board)" according to page 1 of the datasheet and the block diagram.
Best Answer
There are a few things that may be the cause of instability in your PICkit4.
The code you posted could be a lot better so here is a custom crafted PIC16F886 assembly language example for you:
Another thing that may help or brick your PICkit4 is to use the MPLABX Integrated-Programming-Environment(IPE) tool to do a "Hardware Tool Emergency Boot Firmware Recovery".
This is a tricky process that may require a few tries before you do it correctly. You will need to unplug and plug in the PICkit4 at the proper steps in the process.
The worst case for you is that your MPLABX v5.40 installation is somehow corrupt. This will require you to uninstall it, be sure that any remnants of previous MPLABX installs have been deleted, the install it all again. After doing the only 10 or 15 times it becomes only monstrously annoying.