View previous topic :: View next topic |
Author |
Message |
sianko
Joined: 01 Oct 2003 Posts: 2
|
Configuration bits |
Posted: Sat Feb 18, 2006 5:30 am |
|
|
I have such problem. Is here somebody who can advice me how to set PIC18f452 configuration bits in the way , that first three blocks in program memory will be code protected, but last one (06000-07fff) not ? I know how to do it using compiler rev3.239. But i need it for compiler 3.190. PLEASE HELP :o). Thanks a lot.
sianko |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sat Feb 18, 2006 8:17 am |
|
|
Configuration bits are set using the #fuses declaration in your program code. What makes you think the way to set the configuration bits has changed between versions v3.190 and v3.239?
I compared the header file 18f452.h for versions v3.187 and v3.242 and didn't see any changes in names for the fuses. |
|
|
sianko
Joined: 01 Oct 2003 Posts: 2
|
|
Posted: Sat Feb 18, 2006 8:28 am |
|
|
3.190 doesn't know "protect=8" but 3.239 knows it. Generaly, i don't know how to set fuses to set protection for first three blocks, and for last one not, in different way as mentioned. If you know how i can do it , can you give me some example pls.
Regards. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sat Feb 18, 2006 10:35 am |
|
|
Quote: | 3.190 doesn't know "protect=8" but 3.239 knows it. | I didn't know this was a new addition to the compiler, it never appeared in the release notes.
In v3.190 you can use:
- PROTECT, will clear all 4 code protection bits.
- NOPROTECT will set all 4 code protection bits.
You want to clear CP0, CP1 and CP2 but set CP3. I don't know if there is an easy way to achieve that...
The only solutions I can think of are:
1) Manually edit the hex-file (for every release). Don't forget to adjust the checksum as well.
or 2) Change the configuration bits in MPLAB and then save the hex-file using File/Export. Advantage is that MPLab will take care of the checksum.
or 3) Use the program chipedit.exe that comes with PCWH and add a new fuse name to the table of existing fuses for the PIC18F452. For example MY_PROTECT_8 with mask=000F, value=0008, CW=5. Then in your program you can write something like Code: | #fuses HS,NOLVP,MY_PROTECT_8 |
These methods feel clumsy, maybe someone else knows a better method? |
|
|
|