# Micro-Controller copy

Recently I started looking into micro-controllers, I bought a velleman pc serial interface and a serial to usb adapter for programming pics, I have some experience with micro controllers, but some educational micro controller called PICAXE, it is programmed in BASIC and is very user friendly, but I wanted to take the leap and do something larger, that's why I asked a friend if he could get me a pic, I borrowed one he told me he didn't use for a while but should have some program whose code he had lost.

With this, I decided I wanted to recover his code and maybe interpret it and give it back to him as a gift in exchange for the pic and his help. I started digging the web, forums, blogs, everything PIC related to look for this. With the velleman interface (K8076) I was able to connect to the pic (12F629) and allegedly "scan" the program, the output was a .hex file, but I was wondering if I could translate that to something like an .asm file so the program is readable and I can interpret it. This was done with velleman's software, called PicProg2009. Can the whole job of reading the pic be done by MPLab X? i downloaded the latest version, but i dont know much on how to work around with it, so I don't even know how to recognise the interface in MPLab...

Also, what is the OSCCAL Value? it seems to be different everytime i scan the pic for code...

A Last question: Could this interface be used for the same purpose if it was an ATMEL micro-controller?

Best regards,

• You should possibly split your OSCCAL portion into a separate question, it is worthy of a decent answer on its own. – David Dec 30 '13 at 10:21

Yes, this is possible in a number of ways. What you need is a disassembler that supports the target microcontroller you have.

The simplest way to do this for a PIC is to use MPLAB. I use the older version (v8.90) for this but there is most probably a way to do it in MPLABX also. Load the software then choose File->Import and open your .hex file. After this you can use View->Program Memory to see the assembler.

This might not bear much representation to the original code if it was written in a compiled language (for example C), but it will be an accurate representation of the exact instructions the microcontroller would run.

There are other free pieces of software that can do this. You can also find paid offerings like IDA Pro, which become very useful when starting to disassemble bigger portions of code.

• thank you, good answer, i got NOP on every line except for the last one which says RETLW and 4 digits, that seem to be the same value as the OSCALL byte, what does this mean? – Antero Duarte Dec 30 '13 at 10:21
• If you get NOP on every line then it's a blank microcontroller, with the saved oscillator calibration at the end. – David Dec 30 '13 at 10:23
• The PICKit software and MPLAB both have options to check if the PIC is blank. See Programmer->Blank Check All in MPLAB 8. Perhaps see if PicProg2009 has a similar function. – David Dec 30 '13 at 10:25
• thats what i though, but its weird, im at work now and i think we have some 12F629 around in some of our products, if theyre working, they cant be blank, i'll try to get one of these and read it, perhaps it's the interface, i find it very strange that the pic is blank... Thank you anyway :) – Antero Duarte Dec 30 '13 at 10:30
• okay, so i tried loading a pic from my company and im not able to get the program, im getting a blank again, im sure the pic is not blank though, i tested it could this be a problem with the interface? I think the pic might be code protected though, how does this code protection work? could this be the reason im getting a blank file? – Antero Duarte Dec 30 '13 at 11:12