Electronic – Micro-Controller copy

microcontrollermplabxpic

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,

Best Answer

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.

MPLAB disassembly window

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.