| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| cerr 
 
 
 Joined: 10 Feb 2011
 Posts: 241
 Location: Vancouver, BC
 
 
			    
 
 | 
			
				| What's happening with my code protection?? |  
				|  Posted: Wed Jul 13, 2011 12:00 pm |   |  
				| 
 |  
				| 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: 9587
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jul 13, 2011 12:10 pm |   |  
				| 
 |  
				| 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jul 13, 2011 12:10 pm |   |  
				| 
 |  
				| 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jul 13, 2011 12:19 pm |   |  
				| 
 |  
				|  	  | 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: 19962
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jul 13, 2011 2:39 pm |   |  
				| 
 |  
				| 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jul 13, 2011 2:41 pm |   |  
				| 
 |  
				|  	  | 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
 
 
 
			    
 
 |  | 
	
		|  | 
	
		| cerr 
 
 
 Joined: 10 Feb 2011
 Posts: 241
 Location: Vancouver, BC
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jul 13, 2011 3:43 pm |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Jul 13, 2011 4:20 pm |   |  
				| 
 |  
				| Post the code necessary to make those two lines compile. |  | 
	
		|  | 
	
		| asmallri 
 
 
 Joined: 12 Aug 2004
 Posts: 1659
 Location: Perth, Australia
 
 
			        
 
 | 
			
				|  |  
				|  Posted: Thu Jul 14, 2011 12:27 am |   |  
				| 
 |  
				|  	  | cerr wrote: |  	  | 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!!
 |  | 
	
		|  | 
	
		|  |