Read and Write Protection to pic18f4520

microchipmicrocontrollerpic

I am working on pic18f4520 using MPLAB C18 compiler. I have just completed a project (Asked questions about it earlier,see my other posts) and now I want to lock the data of the micro-controller so that no one can read or write it any more. Can anyone plz upload sample of a code on how to protect data in pic18f4520.See images and plz tell my why there is a syntax error

where is the asm file?

Best Answer

If you want to embed it in your C code you can use the pragma config directive to set the fuses. From the PIC18 configuration settings addendum it looks like the PIC18F4520 has four code protect blocks so you'd need the following to protect those and the boot block:

#pragma config CP0 = ON
#pragma config CP1 = ON
#pragma config CP2 = ON
#pragma config CP3 = ON
#pragma config CPB = ON