adamthole said:
I am very new to PIC controllers. I am currently using a pic16f628 with a pg2c programmer and ICProg as my programmer. When I program in circuit with only my 20 MHz crystal installed and one LED (with resistor of course) it will not re-program the chip. However, if I take the crystal out of the circuit it will program with no problem. Is this normal behavior or am I doing something wrong? Any clue where? One thing that may or may not be a culprit is that I am not using any caps on the crystal. I ordered 20pF caps for it, but I wasnt paying close enough attention and actually ordered the 0201 smd package instead of the usual. Imagine my suprise
As explained in another thread, it's VERY bad practice to leave the caps out, and it may, or may not, work - so you should ALWAYS fit them.
However, that's not your problem!.
ICProg isn't an in-circuit programmer, and isn't intended to be used as such, that's what your problem is!.
To switch a PIC to programming mode you apply Vdd (5V), wait a short time, then apply Vpp (13V) to MCLR. Vpp MUST be applied before the oscillator starts running - once it runs you can't select programming mode!.
For in-circuit programming both the programmer and software need to be designed accordingly, so that the software can stop the oscillator - usually by grounding MCLR, and holding the device in reset.
So the in-circuit procedure would be:
1) Hold MCLR LOW - PIC in reset.
2) Turn Vdd ON.
3) Short delay.
4) Switch MCLR directly to 13V.
This enters programming mode without the PIC having time to start oscillating - BTW, a MUCH more common problem is the 16F628 set to internal oscillator, this can have problems even when inserted in the ZIF socket on a programmer.
Most programmers (both hardware and software) don't have the facilities for pulling MCLR LOW - which is what is causing your problem!.