PDA

View Full Version : Problem proramming PIC 16F886 with PICKIT2?



jellis00
- 6th January 2012, 04:02
Have been using my PICKIT2 for years to program PBP into PIC chips on my board apps via ICSP connection. Has always worked great. Especially when using the FineLine IDE.
However in last few days for somereason I am seeing some anomalies. Had to manually select the chip via PICKIT2 user interface even though FLide was telling it the chip type. Then it appeared that it wrote my PBP code to the 16F886 OK when I used the "Auto Import HEX +write device" button on the PICKIT2. I say it looked OK because the program memory window displayed by the PICKIT2 appeared like it had my code.

However, when I try to READ the device with the PICKIT2 GUI READ button, I see all zeros in all the memory addresses and in the EEPROM addresses. I notice also under the Configuration: label on the GUI a message is being displayed in RED color saying "All protect". I have never seen this before. Can anyone tell me what it means and how I can resolve this??

HenrikOlsson
- 6th January 2012, 08:16
I don't have the PICKit2 but it sounds as if the code protection feature of the device is ON. The code most likely IS programmed into the chip, you just can't read it due to thr protection being turned on. Check the device configuration.

jellis00
- 6th January 2012, 15:58
Henrick, you are partially correct. I checked the settings under Tools menu before the READ and the Enable Protects were not checked on either the Program or EPPROM. However, I notice after I click the READ button it appear to go thru the read process, but only shows zeros in both Program and EEPROM memory, the RED colored "All protect" warning appears, and now when I check the Enable Protect settings under the Tools menu they are both selected but grayed out and it is not possible to manually unselect them. I have to exit the PICKIT2 GUI and start over to see them unselected. But then same thing happens.

Hopefully someone who has a PICKIT2 can read this post and tell me what is going on. I can no longer do either a program Write or a Read of program or EEPROM memory and am out of business!

HenrikOlsson
- 6th January 2012, 16:05
Hi,
You need to check the configuration bits before programming the chip.

The whole idea behind them is protect the code from being read out so if you were able to change them in the PICKit2 program AFTER they where written they'd be kind of useless.

Load you .hex file into the software THEN verify that the protect bits aren't set, reprogram the chip - now you should be able to read it back.

/Henrik.

EDIT: If you can't reprogram the chip either, try a full erase first - that should clear the protection bits. I'm not sure if there's a setting or not for that though, my PK3 seems to ALWAYS do an erase before write.

Jerson
- 6th January 2012, 17:36
Just in case you suspect the Pickit2 is out of whack, there is an option in the pk2 user interface(my version is 2.61.00). Tools->"Download Pickit2 OS". Try this if you're out of options.

jellis00
- 6th January 2012, 21:58
I just downloaded & installed Application version 2.61.00 and Device File Version 1.62.14. After doing this I tried to used the PICKIT2 and I get a continuous message of "No Device detected" in a yellow window on the PICKIT2 application GUI.
I also tried your suggestion to use the Tools->"Download Pickit2 OS" feature in the GUI, but it doesn't work on my PICKIT2 application software. The menu does list it but when I click on it, it doesn't go to the internet to look for an update, it just opens Explorer window to look for the file locally in my computer. This doesn't help since the OS update file isn't in my local computer yet.
What I need to know is how to find the latest OS version for PICKIT2 on the web and how to download and install it in my PICKIT2. Can anyone advise me or point me to a tutorial.

jellis00
- 6th January 2012, 22:02
Henrick: After downloading/installing updates to the Application software to v2.61.00 and Device File v1.62.14 I tried to reprogram the chip. At least now the "All Protect" warning is gone and the Enable Protect menu selection in Tools are operable and unselected, indicating the protection bits were cleared. However chip will not program or erase and displays continuous "No device detected" message in yellow window.
Any other suggestions?

Dick Ivers
- 7th January 2012, 02:13
Hi, Check all the connections from Pickit2 to your board. Anything loose or broken, especially ICSP Data and ICSP Clk, will produce that message.

Jerson
- 7th January 2012, 02:15
Jellis00

You can point explorer to the hex file in ProgramFiles\Microchip\Pickkit2 v2 or similar. That is what it is looking for.

as for the yellow box telling you no device found, it is very likely you are connecting the pickit2 to an unpowered board which may be loading the pickit2 resulting in this message. You may also get the ding-dong of USB device disconnection. If this is happening, I advise you should try to program an isolated PIC. No other components on the board. Another way is to power up your board and then try programming with the pickit2. It automatically senses that the board is powered and makes adjustments to its power conditions.

Hope that helps

Dick Ivers
- 7th January 2012, 02:23
Hello again, Another thing to look for: Double check that the power light on the Pickit2 is on. After repeated usage the mini USB connector can break away from the board inside the Pickit2, and it loses power. This happened 3 times with mine ... I repaired it each time.

jellis00
- 7th January 2012, 16:28
Jellis00

You can point explorer to the hex file in ProgramFiles\Microchip\Pickkit2 v2 or similar. That is what it is looking for.



One thing I have considered is that my OS may be contaminated. I want to download the latest OS version for the PICKIt2 and install it to see if that solves the problem. But as I said above, I can't find the latest OS on the web that I can download. Can anyone point me to one?

My PICKIT2 is showing a power light so I don't think that is a problem. However, I will (at Jerson's suggestion) try to isolate any power issues on my application board. Thanks for the ideas.

BH_epuk
- 7th January 2012, 20:34
I have had strange programming issues with the 16F88x series and Pickit2 a while back.
Turned out to be the PGM pin (RB3) on the PIC needs to be pulled down to GND with ~10K - page 228 of the datasheet.

Hope this helps

jellis00
- 8th January 2012, 20:05
I have had strange programming issues with the 16F88x series and Pickit2 a while back.
Turned out to be the PGM pin (RB3) on the PIC needs to be pulled down to GND with ~10K - page 228 of the datasheet.

Hope this helps
BH_epuk: I went to pg 228 in the 16F88x data sheet and the only thing I find that equates to what you are saying is:
"
4: RB3 should not be allowed to float if LVPis enabled. An external pull-down deviceshould be used to default the device tonormal operating mode. If RB3 floatshigh, the PIC16F882/883/884/886/887device will enter Programming mode."

From this quote it appears that what you are saying only applies "if LVP is enabled". I am not enabling LVP so I don't think this applies in my case. In fact, I have RB3 connected to Vcc via a pullup resistor of 10K ohms. Your opinion?

BH_epuk
- 8th January 2012, 20:27
Give it a go with PGM pulled down. I only found this after intermittent programming problems on a project some time ago, now allways keep this pin in a way it can be pulled down (even if it means an extra pad on the PCB).

If the device is new then LVP is enabled - note 5 on P228, but i also suspect if the device is erased is default's back to this.

Edit:

In your case pullde to VCC via 10K, just shorting RB3 to GND while programming would do the trick.

jellis00
- 11th January 2012, 23:23
Finally found the problem. Evidently the 16F886 chip had gone bad. When I replaced it with a new chip everything works fine. Don't understand what caused the chip to fail.
In my next board version, however, I will implement some of your suggestions as far as the PGM pin is concerned.

Thanks for all of your good ideas.
John Ellis