You may not be able to do what you want if any of the code protection bits are set...
Code:
Note: Code protection bits may only be written to a ‘0’ from a ‘1’ state.
It is not possible to write a ‘1’ to a bit in the ‘0’ state.
Code protection bits are only set to ‘1’ by a full Chip Erase or Block Erase function.
The full Chip Erase and Block Erase functions can only be initiated via ICSP or an
external programmer.
Since you can brick the device if you get the config bits incorrect (ie wrong osc type) I like to have the bootloader just ignore reprogramming the config bytes.
Bookmarks