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.

PIC code protection - read 0x00?

Status
Not open for further replies.

BeeBop

Active Member
I was under the impression that if the code protect, or EEPROM protect bits have been set, they may be cleared by erasing the part. Is this true?

Another thing I understand, is that when a part is blank, all registers will read 0xFF, true?

The reason I ask, is that I have a boatload of SOIC 16F628s which I bought on ebay last fall. I finally got around to trying one out, and while the ICD2 can connect, programming fails, and the read is all 0x00. Any ideas?

I wonder if all I have is a bunch of code protected chips, or perhaps they were damaged in some way? This was the worst ebay transaction I have ever had; I had to plead with the seller to send the parts, and then return the first parts he sent because they were not packed well - they had spilled out of the tubes, and were all over the package, and he did not send as many as agreed. I hope I didn't really get screwed, but ...
 
Last edited:
BeeBop said:
I was under the impression that if the code protect, or EEPROM protect bits have been set, they may be cleared by erasing the part. Is this true?
Yes, a bulk erase sets the code protection bits (code protection disabled). Vdd must be 4.5-5.5 V.

BeeBop said:
The reason I ask, is that I have a boatload of SOIC 16F628s which I bought on ebay last fall. I finally got around to trying one out, and while the ICD2 can connect, programming fails, and the read is all 0x00. Any ideas?
If the PIC is code-protected, memory locations are read as 0's. If there is a program already loaded into the PIC and it uses the internal oscillator with MCLR disabled, there might be a problem entering the programming mode. Just a guess, though.
 
Last edited:
blueroomelectronics said:
0x00 usually means your ICD2 doesn't see the PIC.
Hmm, I thought the ICD2 would throw up a warning on trying to connect, but it doesn't.
The cct is very simple, just a PIC mounted on an adapter board, plugged into my development board. I wonder, if I should have added an extra cap on the power pins of the smt chip. There is one on the dev board, but now it is further away from the PIC pins.

The thing is, that if the ICD2 didn't see the PIC, it would read all 0xFF, but my read back is all 0x00s.

eng1 said:
Yes, a bulk erase sets the code protection bits (code protection disabled). Vdd must be 4.5-5.5 V.

O.K., good there, and I'm glad you verified that one for me. :)

eng1 said:
If the PIC is code-protected, memory locations are read as 0's. If there is a program already loaded into the PIC and it uses the internal oscillator with MCLR disabled, there might be a problem entering the programming mode. Just a guess, though.

Yes, memory locations are all 0s.

You may have answered it there, eng1. :( I wonder if my PPT programmer would have better luck?
 
blueroomelectronics said:
0x00 usually means your ICD2 doesn't see the PIC.

That would be 0x3FFF for a blank PIC, 0x000 would be how a modern code protected device reads.

Obvious thing for him to try is erasing the device, and see what it reads then.
 
The ICD2 & PICkit2 both have 4.7K pulldowns on the PGC & PGD pins so a disconnected target will read 0x00
PKWarn0003: Unexpected device ID: Please verify that a PIC18F1320 is correctly installed in the application. (Expected ID = 0x7C0, ID Read = 0x0)
Same error for an ICD2
 
Thanks, everyone, so far, for your help!
The ICD2 & PICkit2 both have 4.7K pulldowns on the PGC & PGD pins so a disconnected target will read 0x00

So you are thinking that one of these is not connected at the micro? I read 0.0V on these but a few hundred millivolts on other PORTB pins....

I'm going to check that each pin of the chip has a good connection to my adapter board...

I'm hoping Bill is right here, but I don't get the warning when trying to connect to the chip, instead, this is the warning I get when trying to read or write to it:


(I'm just clicking OK to dismiss the dialog...)

ICDWarn0052: MPLAB ICD 2 cannot validate a target device. Please make sure that the target device is connected and properly powered. Select "OK" to continue, or "CANCEL" to abort the operation
Then after erase:

Running ICD Self Test
...Passed
...Download Operating System Succeeded
Setting Vdd source to target
...Reading ICD Product ID
Running ICD Self Test
...Passed
MPLAB ICD 2 Ready
Erasing Target Device...
ICDWarn0052: MPLAB ICD 2 cannot validate a target device. Please make sure that the target device is connected and properly powered. Select "OK" to continue, or "CANCEL" to abort the operation
...Erase Succeeded
MPLAB ICD 2 Ready

Then when I try to read:
Reading...
ICDWarn0052: MPLAB ICD 2 cannot validate a target device. Please make sure that the target device is connected and properly powered. Select "OK" to continue, or "CANCEL" to abort the operation
ICDWarn0038: When using auto-calculate write range, reads cover the entire memory range. Do you wish to continue?
...EEPROM
...Program Memory (0x0 - 0x7FF)
.. Config Memory
...User ID Memory
...Read Succeeded
MPLAB ICD 2 Ready
and then view program memory, every location is programmed with 0x0000

On trying to program, I get this warning:
Programming Target...
ICDWarn0052: MPLAB ICD 2 cannot validate a target device. Please make sure that the target device is connected and properly powered. Select "OK" to continue, or "CANCEL" to abort the operation
...Validating configuration fields
...Erasing Part
...Programming EEPROM Memory
...Programming Program Memory (0x0 - 0x59)
...Programming User IDs
Verifying...
ICDWarn0052: MPLAB ICD 2 cannot validate a target device. Please make sure that the target device is connected and properly powered. Select "OK" to continue, or "CANCEL" to abort the operation
...Program Memory
ICD0161: Verify failed (MemType = Program, Address = 0x0, Expected Val = 0x3000, Val Read = 0x0)
ICD0275: Programming failed.
MPLAB ICD 2 Ready
 
It looks like the PIC is not detected! I've just read on the Microchip ICD2 User's Guide that if you attempt to read a code-protected PIC, you get a warning indicating that the device is protected and that the program memory may be invalid.
Also, I've noticed that the following message is missing, after "Setting Vdd source to target":
Target Device PIC16F628 found, revision = ... ??
Shouldn't you get it, even if code-protection is enabled? Unfortunately I can't make a quick test right now.

Even if the ICD has passed the self-test, have you checked if the voltage levels are high enough?
Is there anything connected to RB4 (PGM)?
 
Last edited:
eng1 said:
It looks like the PIC is not detected! I've just read on the Microchip ICD2 User's Guide that if you attempt to read a code-protected PIC, you get a warning indicating that the device is protected and that the program memory may be invalid.
Yes, thanks for clearing that one up. I guess I should re-read it again...

Also, I've noticed that the following message is missing, after "Setting Vdd source to target":
Target Device PIC16F628 found, revision = ... ??
Shouldn't you get it, even if code-protection is enabled? Unfortunately I can't make a quick test right now.
Good catch! I think you are right there; If I change out the chip to another, I get:
Setting Vdd source to target
Target Device PIC16F628A found, revision = Rev 0x8

It must be, then, that, as Bill pointed out, the ICD2 doesn't see the thing.

Even if the ICD has passed the self-test, have you checked if the voltage levels are high enough?
Is there anything connected to RB4 (PGM)?

All the levels seem fine, and nothing connected on B4, but I've run out of time, I'll try some more later.

Thanks!
 
When I have had chips that were programmed with internal oscillator and no Mclr, I found that they wouldn't erase. If I swapped a good one in there during booting, then switched back to the "broken" one and hit erase, it worked.

I think MPLAB has to see a good one so it knows which programming algorithm to use.

Mike.
 
Can your programmer manage Vdd before Vpp . I feel this facility helps to at least identify that the device is there. I also believe that you need to erase the device totally to get rid of the Code protect and the program itself employs internal oscillator. Once erased, the device may behave fresh, unless faulty.
 
hiiii....
Pommie...
m new here...
i m trying to download one program in PIC 16f676..
using microchip MPLAB 2...
but i cant...
can u help me out...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top