Electronics > Beginners

PIC16F722 programing troubles especialy for debug mode

(1/4) > >>

I can program for release but not for debug!

I have connected up a PIC16F722 to an RJ11 header for use with my ICD3. I have supplied power via a 240V to 35V step down transformer, rectified, smoothed with large capacitor and regulated with a LM7805. The output voltage is 5.15V according to the oscilloscope.

I can program the device when I am just programing and not debugging the program works, changing the clock speed and toggling PORTB indefinitely. However when trying to debug the program does not run at all. I often but not always receive the error:

The following memory regions failed to program correctly:
Debug Executive
Programming failed

I am not sure what is going wrong. The problem seems to be worse when I use my own power supply and not the ICD3 on board power supply. So far I am investigating three potential sources of the problem, I am not sure at all if these are the sources I am just guessing at this stage.

1. Capacitance added to the power terminals of my PIC16F722 the ICD3 quick start has a picture showing that no capacitance should be added to the power terminals of the micro, I thought this was a mistake on their part.
2. I have missed a configuration bit required for debugging.
3. Cross talk and or noise on my in circuit serial programing lines.

Any other advice on whether capacitance should be removed from the micro power terminals, or other potential problems I have missed, would be much appreciated.

Here is the simple program I am using to get started.

#include <htc.h>


void main(void)
// port directions: 1=input, 0=output
TRISB = 0b00000000;
OSCCON = 0xff;

while (1){
PORTB = 0xff;
PORTB = 0x00;


The PIC is being used for a switch mode current controlled variable voltage supply, hence the large diode bridge seen on the board. The two other chips are latching BCD to HEX converters and the small MOSFETS are 2N7000's. None of these other components are connected.

Hey there

When I debug any PIC I never add the DEBUG configuration bit, I allow MPLAB to add it for me. I also never code protect the PIC, which is OK in your config function.

I also found some debugging glitches when using compiler optimizations. Try to select the Lite compiling mode of HiTech.

RB7 and RB6 are PGD and PGC. By asking MPLAB to debug your PIC, those pins will be disabled for I/O and enabled for ICSP debugging. It's OK not to connect anything in there such as capacitors, just like you said.

The ICD Vdd and Vss must be directly connected to the Vdd and Vss of the PIC power supply. Do not connect anything between them (such as voltage regulators, diodes, resistors, etc.).

Check, check and check. I tried removing the DEBUGEN from the configuration bits with no change in the problem. Power pins of the PIC are directly connected to the ICD3. I am now beginning to wonder if the little break out board I am using is causing the problems see pictures. Or my PGD and PGC wires are too long (green and blue and white in the picture).

Can still get it to program in program only mode, I guess there is a great deal less communication required for that mode. I have attatched a scope waveform of the PGD signal. Looks a bit messy to me any ideas out there as to weather this could be causing the problem?

pls post your schematics, i will analyze it, i'm an expert on this 8)

An schematic rather than a soldered board would be easier to review.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod