[PIC]Copy from unprotected PIC then programming another PIC

166 views
Skip to first unread message

RANDY ABERNATHY

unread,
Jun 10, 2010, 5:40:16 PM6/10/10
to pic...@mit.edu
Hello:
 
I am fairly new to the PIC family and have some PICs with code in them, the code isn't protected, at least not according to my Melabs programmer and the person from whom I received the PIC.  I want to copy the code and then burn it into another PIC, possibly a different PIC.  This is a newbie question for sure. 
 
The one with the exisiting code is a PIC16C72A and I would like to be able to burn another PIC16C72A and also a Flash version of a PIC.  I have tried just copying and saving the code then burning it into another PIC of the same type but nothing works.  I know that an "include" file needs to be sent with the functional code and am wondering if that is my problem, even trying to burn the code into a PIC of the same type as the one from which the code was copied.
 
Your help will be greatly appreciated

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Jan-Erik Soderholm

unread,
Jun 10, 2010, 5:57:53 PM6/10/10
to Microcontroller discussion list - Public.

On 2010-06-10 23:40, RANDY ABERNATHY wrote:
> Hello:
>
> I am fairly new to the PIC family and have some PICs with code in them,
> the code isn't protected, at least not according to my Melabs programmer
> and the person from whom I received the PIC. I want to copy the code
> and then burn it into another PIC, possibly a different PIC. This is a
> newbie question for sure.
>
> The one with the exisiting code is a PIC16C72A and I would like to be
> able to burn another PIC16C72A

That would probably be OK.

> and also a Flash version of a PIC.

Not "a PIC" as in "any PIC"
You probably want to use the PIC16F72.

> I have tried just copying and saving the code...

"Saving" how ? Using what tool ?
And what did you get efter the "save" ?

> then burning it into another PIC
> of the same type but nothing works.

Burning *how* ?
And what doesn't "work" ??

> I know that an "include" file needs to be sent...

Howe do you know that ? And what "include file" ?
What you need is the HEX file saved from the old PIC
containing the code. Nothing else.

RANDY ABERNATHY

unread,
Jun 10, 2010, 6:11:02 PM6/10/10
to Microcontroller discussion list - Public.
I copied the HEX code directly from the PIC16C72A.  Then I tried just burning it into another PIC16F72A and when I put the chip back into the circuit, nothing worked.  I also tried burning it into a PIC16F72 and that didn't work either.

I am using a Microengineering Labs USB programmer and I also have their EPIC parallel programmer.  This is what I used to copy the code to memory and also to burn the code into the new PIC.  I have tried both with the same results.
 
I hope this helps shed some additional light on the matter.
 
Thanks again,

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Thu, 6/10/10, Jan-Erik Soderholm <jan-erik....@telia.com> wrote:

Michael Watterson

unread,
Jun 10, 2010, 6:20:49 PM6/10/10
to Microcontroller discussion list - Public.
Jan-Erik Soderholm wrote:
>
> Howe do you know that ? And what "include file" ?
> What you need is the HEX file saved from the old PIC
> containing the code. Nothing else.
>
Generally true, but with some Programmers/Applications you will need to
manually set configword/fuses after selection of PIC type.
Could be that's what's wrong.

Bob Blick

unread,
Jun 10, 2010, 6:26:05 PM6/10/10
to Microcontroller discussion list - Public.

On Thu, 10 Jun 2010 15:11:02 -0700 (PDT), "RANDY ABERNATHY" said:
> I copied the HEX code directly from the PIC16C72A.  Then I tried just
> burning it into another PIC16F72A and when I put the chip back into the
> circuit, nothing worked.  I also tried burning it into a PIC16F72 and
> that didn't work either.
>
> I am using a Microengineering Labs USB programmer and I also have their
> EPIC parallel programmer.  This is what I used to copy the code to memory
> and also to burn the code into the new PIC.  I have tried both with the
> same results.

A couple of things come to mind.

One is that the PIC may actually be protected so the data you read from
it is bad.

The second is that the fuses may not be getting saved correctly, so your
new PIC, although programmed correctly, may have the wrong oscillator or
WDT setting.

Cheerful regards,

Bob

--
http://www.fastmail.fm - One of many happy users:
http://www.fastmail.fm/docs/quotes.html

Jan-Erik Soderholm

unread,
Jun 10, 2010, 6:27:24 PM6/10/10
to Microcontroller discussion list - Public.

On 2010-06-11 00:11, RANDY ABERNATHY wrote:

> I copied the HEX code directly from the PIC16C72A.

To what ? Did you get a .HEX file ?

> Then I tried just
> burning it into another PIC16F72A and when I put the chip back into the
> circuit, nothing worked. I also tried burning it into a PIC16F72 and
> that didn't work either.

Your software should probably have said exactly how much it
burned into the PIC's. What those figures reasonable
and what you expected ? That is, compared to how much it
read from the original PIC ?

Isaac Marino Bavaresco

unread,
Jun 10, 2010, 6:29:43 PM6/10/10
to Microcontroller discussion list - Public.
Em 10/6/2010 19:11, RANDY ABERNATHY escreveu:
> I copied the HEX code directly from the PIC16C72A. Then I tried just burning it into another PIC16F72A and when I put the chip back into the circuit, nothing worked. I also tried burning it into a PIC16F72 and that didn't work either.
>

Did you save the file in the HEX file format? It is not just a binary
image, it is a formated text file with hexadecimal number in it, with a
definite structure.

Did you read back the PIC that you just programmed? Did the file compare
with the original?

Try opening the original hex file in MPLAB and check in the program
memory window to see if the instructions make sense.


Best regards,

Isaac

__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/

RANDY ABERNATHY

unread,
Jun 10, 2010, 7:06:49 PM6/10/10
to Microcontroller discussion list - Public.
Thanks, I take it that the programmer may report no protection but in reality there might be protection.  I do have the exact same PIC with almost the exact code that does show protection is ON.  The PIC I am trying to read and copy is one with some minor changes that were made to the code in the protected chip.  When I read it the protection shows OFF.  However, I will be the first to admit things are not always the way they appear.  I will check regarding the fuses you mention.

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Thu, 6/10/10, Bob Blick <bobb...@ftml.net> wrote:


From: Bob Blick <bobb...@ftml.net>
Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC
To: "Microcontroller discussion list - Public." <pic...@mit.edu>

RANDY ABERNATHY

unread,
Jun 10, 2010, 7:08:46 PM6/10/10
to Microcontroller discussion list - Public.
According to the programmer software, when it verified the burn, it was OK.

RANDY ABERNATHY

unread,
Jun 10, 2010, 7:10:42 PM6/10/10
to Microcontroller discussion list - Public.
I didn't exactly do what  you are suggesting so I will try that.  I did compare the code in the newly burned PIC to the code I copied from the original PIC and it did appear to match.  Of course I could have missed something.

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Thu, 6/10/10, Isaac Marino Bavaresco <isaacba...@yahoo.com.br> wrote:

ivp

unread,
Jun 10, 2010, 7:30:14 PM6/10/10
to Microcontroller discussion list - Public.
> I take it that the programmer may report no protection but in
> reality there might be protection

If you look at the hex file you'd soon find out whether you have blank
data. Are you doing this through an editor or just chip-to-chip ?

Bob Blick

unread,
Jun 10, 2010, 7:49:00 PM6/10/10
to Microcontroller discussion list - Public.

On Fri, 11 Jun 2010 11:30:14 +1200, "ivp" said:
> > I take it that the programmer may report no protection but in
> > reality there might be protection
>
> If you look at the hex file you'd soon find out whether you have blank
> data. Are you doing this through an editor or just chip-to-chip ?
>

I remember the old eprom PICs read out data when protected, but one of
the bits was always high or something like that. But just looking at it,
you'd think you read real program memory.

Cheers, Bob

--
http://www.fastmail.fm - Does exactly what it says on the tin

Oli Glaser

unread,
Jun 10, 2010, 8:34:05 PM6/10/10
to Microcontroller discussion list - Public.

--------------------------------------------------


From: "Isaac Marino Bavaresco" <isaacba...@yahoo.com.br>

Sent: Thursday, June 10, 2010 11:29 PM


To: "Microcontroller discussion list - Public." <pic...@mit.edu>
Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC

> Em 10/6/2010 19:11, RANDY ABERNATHY escreveu:


>> I copied the HEX code directly from the PIC16C72A. Then I tried just
>> burning it into another PIC16F72A and when I put the chip back into the
>> circuit, nothing worked. I also tried burning it into a PIC16F72 and
>> that didn't work either.
>>
>
> Did you save the file in the HEX file format? It is not just a binary
> image, it is a formated text file with hexadecimal number in it, with a
> definite structure.
>
> Did you read back the PIC that you just programmed? Did the file compare
> with the original?
>
> Try opening the original hex file in MPLAB and check in the program
> memory window to see if the instructions make sense.

If you are doing this remember to set the correct processor in
configure->select device, otherwise it may interpret the opcodes incorrectly
IIRC. Then you can step through the dissassembly using MPLAB SIM if you
wish, to see if the code runs correctly.

ivp

unread,
Jun 10, 2010, 9:20:28 PM6/10/10
to Microcontroller discussion list - Public.
> I remember the old eprom PICs read out data when protected, but
> one of the bits was always high or something like that. But just looking
> at it, you'd think you read real program memory

Yes, the OP has a 16C, which I've not used, so can't comment. Most
of my time with 16s was 16F using MPLAB and the PICStartPlus.
Those two together will not give you useable data from a protected chip
(IIRC the file is all 3FFF), as you'd hope from protection

If Randy's 16C is unprotected the contents should be able to be read,
edited, confirmed and written, like any imported hex file

Craig Stevens

unread,
Jun 10, 2010, 11:53:15 PM6/10/10
to Microcontroller discussion list - Public.
Are you erasing the chip before programming?
Have you erased its clock calibration?heers
Craig

c

Sarin Sukumar A

unread,
Jun 11, 2010, 12:50:18 AM6/11/10
to Microcontroller discussion list - Public.
YOurs SaRIn....


On Thu, Jun 10, 2010 at 4:10 PM, RANDY ABERNATHY <
randyab...@bellsouth.net> wrote:

> I didn't exactly do what you are suggesting so I will try that. I did
> compare the code in the newly burned PIC to the code I copied from the
> original PIC and it did appear to match. Of course I could have missed
> something.
>

If you try with Pickit2 you might get good results...

Tamas Rudnai

unread,
Jun 11, 2010, 2:51:36 AM6/11/10
to Microcontroller discussion list - Public.
I have never used C parts so I might wrong, however, I always thought that
you cannot read the program out as that is for OTP / production, not for
development. Can you confirm, that the data you read out is valid?

Tamas

--
int main() { char *a,*s,*q; printf(s="int main() { char *a,*s,*q;
printf(s=%s%s%s, q=%s%s%s%s,s,q,q,a=%s%s%s%s,q,q,q,a,a,q); }",
q="\"",s,q,q,a="\\",q,q,q,a,a,q); }

Xiaofan Chen

unread,
Jun 11, 2010, 3:11:40 AM6/11/10
to Microcontroller discussion list - Public.
On Fri, Jun 11, 2010 at 12:50 PM, Sarin Sukumar A
<sarins...@gmail.com> wrote:
> If you try with Pickit2 you might get good results...

No, PICKit 2 does not support the OTP parts like 16C72A.
PICkit 3 and MPLAB ICD 2 do not support OTP parts either.
Last time when I worked with 16C72A, I was using Promate II.
But PICStart+ and PM3 should work as well.


--
Xiaofan http://mcuee.blogspot.com

Xiaofan Chen

unread,
Jun 11, 2010, 3:12:37 AM6/11/10
to Microcontroller discussion list - Public.
On Fri, Jun 11, 2010 at 2:51 PM, Tamas Rudnai <tamas....@gmail.com> wrote:
> I have never used C parts so I might wrong, however, I always thought that
> you cannot read the program out as that is for OTP / production, not for
> development. Can you confirm, that the data you read out is valid?

You can of course read back the contend of the OTP chip
if they are not protected. If not, how do you verify the chip?

--
Xiaofan http://mcuee.blogspot.com

Xiaofan Chen

unread,
Jun 11, 2010, 3:18:55 AM6/11/10
to Microcontroller discussion list - Public.
On Fri, Jun 11, 2010 at 6:11 AM, RANDY ABERNATHY
<randyab...@bellsouth.net> wrote:
> I copied the HEX code directly from the PIC16C72A.
> Then I tried just burning it into another PIC16F72A and when I
> put the chip back into the circuit, nothing worked.  I also tried
> burning it into a PIC16F72 and that didn't work either.

16C72A and 16F72 are not the same, you may have to change some
settings to get it work.

There are no such thing as PIC16F72A.

And be careful there are PIC16C72 and PIC16C72A. They are
not the same.


--
Xiaofan http://mcuee.blogspot.com

Xiaofan Chen

unread,
Jun 11, 2010, 3:14:45 AM6/11/10
to Microcontroller discussion list - Public.
On Fri, Jun 11, 2010 at 11:53 AM, Craig Stevens <cr...@catalyst.net.au> wrote:
> Are you erasing the chip before programming?
> Have you erased its clock calibration?heers

PIC16C72A has no calibration part. And it is an OTP part,
so no erase actually. You can blank check it. If it is not
blank, pretty much you can not use it any more (not
exactly right, since there are tricks to use it in certain
cases, but that is just exception).

--
Xiaofan http://mcuee.blogspot.com

Oli Glaser

unread,
Jun 11, 2010, 3:41:05 AM6/11/10
to Microcontroller discussion list - Public.

--------------------------------------------------
From: "Xiaofan Chen" <xiao...@gmail.com>
Sent: Friday, June 11, 2010 8:14 AM
To: "Microcontroller discussion list - Public." <pic...@mit.edu>


Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC

> On Fri, Jun 11, 2010 at 11:53 AM, Craig Stevens <cr...@catalyst.net.au>

> wrote:
>> Are you erasing the chip before programming?
>> Have you erased its clock calibration?heers
>
> PIC16C72A has no calibration part. And it is an OTP part,
> so no erase actually. You can blank check it. If it is not
> blank, pretty much you can not use it any more (not
> exactly right, since there are tricks to use it in certain
> cases, but that is just exception).

I *think* they did have a JW suffix for a windowed version of this part that
could be erased. Its possible the OP has this version.

Olin Lathrop

unread,
Jun 11, 2010, 8:02:57 AM6/11/10
to Microcontroller discussion list - Public.
RANDY ABERNATHY wrote:
> The one with the exisiting code is a PIC16C72A and I would like to be
> able to burn another PIC16C72A

That should work if your original PIC truly isn't code protected and your
programmer+software reads back everything. Check your programmer software
docs. Maybe it needs some option to read back everything into a HEX file?

Why not create a HEX file again from the source code?

> and also a Flash version of a PIC.

There will most likely be config bit differences, and possibly memory map
differences depending on how different a PIC you chose. These should be
small changes to the source code if it was written right, then rebuild for
the new PIC from there.

Olin Lathrop

unread,
Jun 11, 2010, 8:20:59 AM6/11/10
to Microcontroller discussion list - Public.
Tamas Rudnai wrote:
> I have never used C parts so I might wrong, however, I always thought
> that you cannot read the program out as that is for OTP / production,
> not for development.

No, you can read C parts as long as they are not code protected. Think
about it. How else would the programmer be able to verify the code got into
the part correctly.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

RANDY ABERNATHY

unread,
Jun 11, 2010, 6:24:54 PM6/11/10
to Microcontroller discussion list - Public.
Isaac:
 
I was told you couldn't disassemble the HEX code when read from the PIC.  From what you are telling me I can.  That would enormously helpful if I can. This code is so old that the original source code no longer exists but I do have, what I have told, is an unprotected OTP chip.  My Melabs programmer also indicates it is unprotected so I am assuming it is.  I also had a typo in the post to which you responded, when I said I tried burning it into "another PIC16F72A" I meant "another PIC16C72A" of course.
 
I will see if I can do what you suggest, that would be fantastic if I can.  Please bear with me, I am pretty new to the PICs and have been finding out they are somewhat different from the older MCUs I have worked with like the 8051 - 8052 stuff.
 
Many thanks to you and everyone for all the suggestions and help.

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Thu, 6/10/10, Oli Glaser <oli.g...@talktalk.net> wrote:

RANDY ABERNATHY

unread,
Jun 11, 2010, 6:29:05 PM6/11/10
to Microcontroller discussion list - Public.
I would say chip to chip since I have  been reading the old PIC with my programmer then inserting another and attempting to burn it.  I know that normally, when a PIC is protected you usually show all FFFF in the memory and the protected chips I do have show exactly that, however this one does not, it has different HEX data in each address location which leads me to think it truly isn't protected.  The person that sent it to me said it wasn't.  It is from a rather old controller that operates a heater, fan, etc. and he couldn't find any of the actual source code left in his files.  Which doesn't surprise me.

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Thu, 6/10/10, ivp <joeco...@clear.net.nz> wrote:


From: ivp <joeco...@clear.net.nz>
Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC
To: "Microcontroller discussion list - Public." <pic...@mit.edu>

RANDY ABERNATHY

unread,
Jun 11, 2010, 6:31:56 PM6/11/10
to Microcontroller discussion list - Public.
Sorry, that was a typo and it should have read "another PIC16C72A"  I realize there isn't a PIC16F72A but there is a PIC16F72.  I was tired and am getting old.

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Fri, 6/11/10, Xiaofan Chen <xiao...@gmail.com> wrote:


From: Xiaofan Chen <xiao...@gmail.com>
Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC
To: "Microcontroller discussion list - Public." <pic...@mit.edu>

Olin Lathrop

unread,
Jun 11, 2010, 6:43:46 PM6/11/10
to Microcontroller discussion list - Public.
RANDY ABERNATHY wrote:
> I was told you couldn't disassemble the HEX code when read from the
> PIC. From what you are telling me I can.

Of course you can. Obviously the machine can interpret each instruction, so
some interpretation program could too. The problem is that while it is
possible to create a assembly file that results in the code you have, it's
only the bare instructions. It won't tell you the intent of the programmer,
and all original label names, comments, and module structure will be lost.

All in all, if you've managed to lose the source code (look up something
called "backups"), it's probably easier to start with the spec and write the
code from scratch than to reverse engineer the dissassembly result.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

Isaac Marino Bavaresco

unread,
Jun 11, 2010, 6:43:49 PM6/11/10
to Microcontroller discussion list - Public.
Em 11/6/2010 19:29, RANDY ABERNATHY escreveu:
> I would say chip to chip since I have been reading the old PIC with my programmer then inserting another and attempting to burn it. I know that normally, when a PIC is protected you usually show all FFFF in the memory and the protected chips I do have show exactly that, however this one does not, it has different HEX data in each address location which leads me to think it truly isn't protected. The person that sent it to me said it wasn't. It is from a rather old controller that operates a heater, fan, etc. and he couldn't find any of the actual source code left in his files. Which doesn't surprise me.
>


By my experience, PICs read all FFs when erased and all 00s when protected.
Make sure you aren't reading an erased chip (or perhaps you erased it by
accident while messing around with your programmer).

Best regards,
Isaac

__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/

--

Olin Lathrop

unread,
Jun 11, 2010, 6:46:31 PM6/11/10
to Microcontroller discussion list - Public.
RANDY ABERNATHY wrote:
> It is from a rather old controller
> that operates a heater, fan, etc. and he couldn't find any of the
> actual source code left in his files.

Idiot alert! Unless he's paying you a lot, get out of there fast.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

Olin Lathrop

unread,
Jun 11, 2010, 6:48:56 PM6/11/10
to Microcontroller discussion list - Public.
Isaac Marino Bavaresco wrote:
> (or perhaps you erased it
> by accident while messing around with your programmer).

Not possible, since this is a OTP part. It is possible to set 1 bits to 0,
but not to erase them back to 1s.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

Isaac Marino Bavaresco

unread,
Jun 11, 2010, 6:53:36 PM6/11/10
to Microcontroller discussion list - Public.
Em 11/6/2010 19:24, RANDY ABERNATHY escreveu:
> Isaac:
>
> I was told you couldn't disassemble the HEX code when read from the PIC. From what you are telling me I can. That would enormously helpful if I can. This code is so old that the original source code no longer exists but I do have, what I have told, is an unprotected OTP chip. My Melabs programmer also indicates it is unprotected so I am assuming it is. I also had a typo in the post to which you responded, when I said I tried burning it into "another PIC16F72A" I meant "another PIC16C72A" of course.
>
> I will see if I can do what you suggest, that would be fantastic if I can. Please bear with me, I am pretty new to the PICs and have been finding out they are somewhat different from the older MCUs I have worked with like the 8051 - 8052 stuff.
>
> Many thanks to you and everyone for all the suggestions and help.
>

1 - Make sure your file is really HEX file format compliant with ".hex"
extension;
2 - In MPLAB IDE:
a) click "Configure" -> "Select Device" and select the correct device;
b) Click "File" -> "Import" and import the file;
c) Click "View" -> "Program Memory", tab "Symbolic".


Best regards,

Isaac


PS.: If your file is not a real HEX file but rather a binary file, there
are old command-line tools often called "bin2hex.exe" or the like that
can convert from binary to a valid HEX file.

__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/

--

MCH

unread,
Jun 11, 2010, 7:05:53 PM6/11/10
to Microcontroller discussion list - Public.
You can read it, but I think any original labels will be replaced with
their generic chip references.

For example, a jump to something called "display" will be replaced with
jump to (address), and store to Displaylocation will be replaced with
store to (address). And of course any notes or comments will not be there.

Joe M.

> ------------------------------------------------------------------------
>
>
> Internal Virus Database is out of date.
> Checked by AVG - www.avg.com
> Version: 9.0.783 / Virus Database: 271.1.1/2746 - Release Date: 03/14/10 03:33:00

Tamas Rudnai

unread,
Jun 11, 2010, 8:31:19 PM6/11/10
to Microcontroller discussion list - Public.
On Fri, Jun 11, 2010 at 11:24 PM, RANDY ABERNATHY <
randyab...@bellsouth.net> wrote:

> I was told you couldn't disassemble the HEX code when read from the PIC.
> From what you are telling me I can. That would enormously helpful if I can.
> This code is so old that the original


You may can give a go with this tool I wrote a while back:

http://www.mcuhobby.com/articles.php?article_id=9

Tamas

--

int main() { char *a,*s,*q; printf(s="int main() { char *a,*s,*q;
printf(s=%s%s%s, q=%s%s%s%s,s,q,q,a=%s%s%s%s,q,q,q,a,a,q); }",
q="\"",s,q,q,a="\\",q,q,q,a,a,q); }

Dwayne Reid

unread,
Jun 11, 2010, 8:46:28 PM6/11/10
to Microcontroller discussion list - Public.
At 03:40 PM 6/10/2010, RANDY ABERNATHY wrote:
>Hello:
>
>I am fairly new to the PIC family and have some PICs with code in
>them, the code isn't protected, at least not according to my Melabs
>programmer and the person from whom I received the PIC. I want to
>copy the code and then burn it into another PIC, possibly a
>different PIC. This is a newbie question for sure.

I don't have any experience with the MELABS programmer so all I can
is suggest a couple of things.

First, and most important: Make Sure that your programmer is set up
to work with the exact chip that you are trying to copy.

1) Your programmer software probably has somewhere that you can pick
and choose what you are going to read and program. For your 'C'
chip, pretty much all you need to read and program is the program
memory and the configuration bits.

That means that you have to tell your programmer to read both the
program and configuration. Check the menus to see if there is
somewhere that you can check or change those settings.

2) When you put your chip with the program that you want to copy into
the programmer and hit the 'Read' button, you place a copy of the
contents of that chip into your computer's RAM.

3) If you now place a blank chip in the programmer socket, you can
hit the 'Program' button and program that brand-new empty chip with
what you read from the first chip.

That's pretty much all that you need to do.

Couple of things to check on first:

1) Make sure that your programmer is reading and writing the
configuration bits. Your brand-new PIC with a perfect copy of the
program burned into it still won't run if the configuration bits are wrong.

2) Make sure that those new chips that you are trying to program are
in fact brand-new and have not already been programmed with
anything. That particular PIC family is One Time Programmable (OTP)
and you can generally only program them once.

If nothing seems to work, see if you can find someone with a PIC
Start Plus programmer. I could then give you an exact step-by-step
procedure on how to copy your original PIC into a new one.

Hope this helps!

dwayne

--
Dwayne Reid <dwa...@planet.eon.net>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax
www.trinity-electronics.com
Custom Electronics Design and Manufacturing

RANDY ABERNATHY

unread,
Jun 11, 2010, 10:03:29 PM6/11/10
to Microcontroller discussion list - Public.
Thanks, I assumed any disassembly would lose comments, etc.  It is the same with other MCUs with which I have worked in the past.  Although I can't say I haven't done something that stupid, it wasn't me this time.  Someone else lost the source code for this one.  I am beginning to think it might be easier to just do this from scratch myself.
 
Thanks again,

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Fri, 6/11/10, Olin Lathrop <olin_p...@embedinc.com> wrote:


From: Olin Lathrop <olin_p...@embedinc.com>
Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC
To: "Microcontroller discussion list - Public." <pic...@mit.edu>

RANDY ABERNATHY

unread,
Jun 11, 2010, 10:05:49 PM6/11/10
to Microcontroller discussion list - Public.
This chip doesn't read all 0000 or all FFFF.  Regardless, I am pretty certain this one is not erased. 

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Fri, 6/11/10, Isaac Marino Bavaresco <isaacba...@yahoo.com.br> wrote:


From: Isaac Marino Bavaresco <isaacba...@yahoo.com.br>

Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC
To: "Microcontroller discussion list - Public." <pic...@mit.edu>
Date: Friday, June 11, 2010, 6:43 PM

RANDY ABERNATHY

unread,
Jun 11, 2010, 10:07:39 PM6/11/10
to Microcontroller discussion list - Public.
Olin:
 
I am afraid this is a "government" job for my brother-in-law and I am working on it whenever I get the time.  I am retired anyway and this just helps keep what little brain I have left working.  But, you are correct this would a good one for an "idiot alert"

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Fri, 6/11/10, Olin Lathrop <olin_p...@embedinc.com> wrote:


From: Olin Lathrop <olin_p...@embedinc.com>
Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC
To: "Microcontroller discussion list - Public." <pic...@mit.edu>

RANDY ABERNATHY

unread,
Jun 11, 2010, 10:10:32 PM6/11/10
to Microcontroller discussion list - Public.
Olin also the persone that deleted his source code is just  guy that had done basically the same type of thing for himself for a wood heater in his house.  I can guarantee if I had written the original code I would have every version I created right from the first line.  Guess I am a pack rat in that sense.  I do use up a lot of disk space that way tho. 

Randy Abernathy
CNC and Industrial Machinery
service, repair, installation and
design

4626 Old Stilesboro Rd NW
Acworth, GA 30101
Fax: 770-974-5295
Phone: 678-982-0235
E-mail:
randyab...@bellsouth.net

--- On Fri, 6/11/10, Olin Lathrop <olin_p...@embedinc.com> wrote:


From: Olin Lathrop <olin_p...@embedinc.com>
Subject: Re: [PIC]Copy from unprotected PIC then programming another PIC
To: "Microcontroller discussion list - Public." <pic...@mit.edu>
Date: Friday, June 11, 2010, 6:46 PM

Reply all
Reply to author
Forward
0 new messages