Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Weird, or Normal Programming Error?

Status
Not open for further replies.

adamthole

New Member
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 :)

Any ideas? Need any more info?
 
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!.
 
16F628 requires the application of Vpp (+13V) before the Vdd (+5V) for it to enter programming mode.

This can be achieved by two methods. First, one applies Vdd, then pull MCLR low to reset the PIC and immediately pull MCLR HIGH to enter the programming mode as Nigel has mentioned. Or you must use a programmer that applies Vpp first.

The programmer you are using is a serial port one that applies Vdd continously to the socket and the ICSP leads. In ICSP configuration, as Vdd is already present, PIC will start running/executing your program immediately because the crystal is also there. Removing the crystal stops it from running so when later the programmer raises the MCLR to Vpp, it will enter programming mode.

This is the reason why removing the crystal works.

However, beware if you config the PIC to use internal oscillator, then it will run with just 5V to Vdd and no crystal needed so you will no longer be able to program it using either ICSP leads or the socket of your programmer.

Again as Nigel has said, your programmer do not have a mechanism that pull MCLR LOW to reset it so that the PIC can enter programming mode. It is much better to consider making/buying one that does.
 
eblc1388 said:
16F628 requires the application of Vpp (+13V) before the Vdd (+5V) for it to enter programming mode.

It doesn't "require" it, but it has the capability of operating in that way.

However, beware if you config the PIC to use internal oscillator, then it will run with just 5V to Vdd and no crystal needed so you will no longer be able to program it using either ICSP leads or the socket of your programmer.

It still programs fine in a programmer, you just have to make sure you don't give the oscillator time to start running - the datasheet gives the spec for this. WinPicProg makes this time interval a user setting, so you can set it accordingly - and 16F628's program fine, even using the internal oscillator (which I always do).
 
No. It won't program in his programmer if he chose internal oscillator for the PIC. Of course we both meant the same thing differently.
 
and here, I still use the AT89C2051 ;-)

anyways, first of all, check the chip to make sure that the chip can work! My uC outputs a signature of: 1Eh 21h when it is working, and when it doesn't work, random output appears along with a hot chip. Yes, I learned the hard way (3 of 4 chips toasted, $9 down the toilet for me.) by not making a programmer with a verify feature installed.

I have not used PIC's yet, and if a working PIC is supposed to produce a certain and fixed output when certain bits are set and you don't see that output, then you need a new PIC. If your PIC is heating up, then take it out of the socket IMMEDIATELY or you could end up blowing up other chips in your programmer ($30+ down the toilet for you).

Once the chip works, you need to treat it like a CDRW. CDRW's must be formatted before the data can be changed on them. There might be some uC's which do not require a data erase before reprogramming, but my uC does.

So erase your chip completely before reprogramming. If your chip has a circular window in it, then I'm afraid that data erasing times could take a while. You will need special lighting for it.

Next, program the data, and set your chip up so that it reads the data as if it was a binary file. Make sure it is programmed correctly.

Also, try lowering your VPP to 12.5V, not 13V. Maybe 13V damages the chip. My chip only accepts 11.5 to 12.5V for VPP.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top