Yes, both things are possible
you can protect code in a microcontroller from being copied by others
and you can get the code back from HEX file
to protect the code: you need to enable lock bits (I am talking about 89s51)
and to get code from Hex file you need assembler, once i have converted using batronix but the converted code was hard to understand...
You can't read it back, but you can erase the chip and re-write to it.
Unless it's a sensitive and valuble application it's best not to read-protect it though - and even then, if it's valuable enough, it can be read by various nefarious means.
While going through the compiler help file, I see that there are Code Protection blocks in PIC18F4520.
If i lock all the 4 (CP0 - CP3) blocks, and leave the Configuration Register Write Protection bit to disable, can someone change my Code protection blocks by writing on the configuration register?
While going through the compiler help file, I see that there are Code Protection blocks in PIC18F4520.
If i lock all the 4 (CP0 - CP3) blocks, and leave the Configuration Register Write Protection bit to disable, can someone change my Code protection blocks by writing on the configuration register?
Note that as Nigel already said, there are other means of reading code back. Microchip have improved in this area recently.
Have a read of some of these links if you are interested:
Breaking copy protection in microcontrollers (mostly historical)
**broken link removed** (historical)
**broken link removed** (search their site for "Microchip" to find teardowns)
As I already said, many of these things have been improved to the point that the attacks won't work any longer. But it proves the point that you cannot rely 100% on code protection and therefore should not feel like it is protecting your intellectual property. It's just putting another (arguably large) barrier in the way.
There was a really interesting site with detailed pictures of the Microchip code protection fuses and how to erase them with UV by exposing the dye with acid. But I don't appear to have it bookmarked. Edit: it's here: **broken link removed**