CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Configuration bits

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sianko



Joined: 01 Oct 2003
Posts: 2

View user's profile Send private message

Configuration bits
PostPosted: Sat Feb 18, 2006 5:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Feb 18, 2006 8:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Feb 18, 2006 8:28 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Feb 18, 2006 10:35 am     Reply with quote

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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group