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

What's happening with my code protection??

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



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

What's happening with my code protection??
PostPosted: Wed Jul 13, 2011 12:00 pm     Reply with quote

Hi There,

I'm seeing odd things with my code protection.
I am using #fuses PROTECT in my code to enable code protection on my pic18f86k22.
I however am still able to read out the code with PICkit3. And when i look at CONFIG5L, it is set to 0x02. But I believe it ought to be 0x00. Is it safe to set it to 0 from within my code? Why isn't this done correctly by my app?

Also, CONFIG5H is set to 0x30 and I'm wondering why as bit 4 and 5 are Unimplemented bit, read as ‘0 - any clues?

Thank you!
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 12:10 pm     Reply with quote

Silly question but are you really reading the PIC and not just seeing the 'ghost' program from your last session?
Sure test is to bootup MPLAB,do NOT load ANY projects and then read the device to confirm you're really reading from it.
I've been fooled before.....
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 12:10 pm     Reply with quote

Even after setting CONFIG5L and CONFIG5H to 0, I'm able to read out the memory properly with my Pickit. Also after setting both to 0, CONFIG5H still reads 0x30...
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 12:19 pm     Reply with quote

temtronic wrote:
Silly question but are you really reading the PIC and not just seeing the 'ghost' program from your last session?
Sure test is to bootup MPLAB,do NOT load ANY projects and then read the device to confirm you're really reading from it.
I've been fooled before.....

I did exactly this (just used PICKit3 before to read) with MPLAB (new session, no project opened) I read from my chip, after the read i can open the program memory window and it's all there, no protection whatsoever... :(
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 2:39 pm     Reply with quote

If you are working from MPLAB, you need to switch out of 'debug' mode here. This setting is the default now, and _overrides_ the fuse settings.

Separately, if you have 'debug' mode selected in the code, this too disables certain fuses (including protection).

Best Wishes
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 2:41 pm     Reply with quote

Ttelmah wrote:
If you are working from MPLAB, you need to switch out of 'debug' mode here. This setting is the default now, and _overrides_ the fuse settings.

Separately, if you have 'debug' mode selected in the code, this too disables certain fuses (including protection).

Best Wishes

Yep,

code is compiled in Release mode and i'm not using debug either, my fuses look like this:
Code:
#case
#device adc=16 HIGH_INTS=TRUE

#fuses WDT256,WDT_SW                //Watch Dog Timer uses 1:65536 Postscale
#fuses HSH                          //Hi-Speed crystal oscillator
#fuses BORV30                  //Brownout reset at 3V tripping level
#fuses NOPLLEN                  //No PLL enabled
#fuses BBSIZ1K                     //1K words Boot Block size
#fuses NOXINST                     //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#fuses PROTECT                  //Enable code protection
#fuses SOSC_DIG
#fuses PUT                     //Enable PowerUpTimer
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 3:11 pm     Reply with quote

The PROTECT fuse doesn't protect the Boot Block. That's a separate fuse:
http://www.ccsinfo.com/forum/viewtopic.php?t=42201
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 3:43 pm     Reply with quote

PCM programmer wrote:
The PROTECT fuse doesn't protect the Boot Block. That's a separate fuse:
http://www.ccsinfo.com/forum/viewtopic.php?t=42201

Well yeah but still, I do a
Code:
CONFIG5L = 0x00;
CONFIG5H = 0x00;

after i enter my main but still, nothing.... any other clues? I also posted in the Microchip forum...

Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 13, 2011 4:20 pm     Reply with quote

Post the code necessary to make those two lines compile.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Jul 14, 2011 12:27 am     Reply with quote

cerr wrote:
PCM programmer wrote:
The PROTECT fuse doesn't protect the Boot Block. That's a separate fuse:
http://www.ccsinfo.com/forum/viewtopic.php?t=42201

Well yeah but still, I do a
Code:
CONFIG5L = 0x00;
CONFIG5H = 0x00;

after i enter my main but still, nothing.... any other clues? I also posted in the Microchip forum...

Thanks!


If you are using Microchip's IDE then make sure you have the config setting to use the fuses in the code.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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