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

#fuses - set in code don´t seems to work

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



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

#fuses - set in code don´t seems to work
PostPosted: Wed Jan 30, 2008 9:33 am     Reply with quote

Hello superforum,

I have tried to put the configuration bits in code with the #fuses but it seems to not work well.
When I e.g. change NOPROTECT to PROTECT nothing happened in the checksum after compilation in MPLAB.
Also when I look in the generated *.lst file I can see that nothing happen when I change the fuses.
The processor is PIC16F883.
Compiler ver. is 4.056
What can be wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 30, 2008 9:55 am     Reply with quote

I compiled the following test program with vs. 4.056.
Code:
#include <16F883.h>
#fuses HS, PROTECT
#use delay(clock=20000000)
//==================================
void main()
{

while(1);
}

The following fuses were at the end of the .LST file:
Code:

Configuration Fuses:
   Word  1: 2FA2   HS NOWDT PUT MCLR PROTECT NOCPD
                   BROWNOUT IESO FCMEN NOLVP NODEBUG
   Word  2: 3FFF   NOWRT BORV40


I then changed the fuse in the test program to NOPROTECT and
re-compiled. I got this in the .LST file:
Code:
Configuration Fuses:
   Word  1: 2FE2   HS NOWDT PUT MCLR NOPROTECT NOCPD
                   BROWNOUT IESO FCMEN NOLVP NODEBUG
   Word  2: 3FFF   NOWRT BORV40

It's working OK. There is no problem.
Mortenc



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Wed Jan 30, 2008 2:46 pm     Reply with quote

Thanks, I have tried your simple testprogram also and it work also at at me.
I can see now that it is because I also have the line:

# device ICD=TRUE

When I use this the fuses don´t work.
I have put in this because the code had to be combatible with Microchip ICD 2 and MPLAB.
Am I wrong about using this?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 30, 2008 5:06 pm     Reply with quote

Look in the help file for the ICD2 in MPLAB. It says this:
Quote:

Requirements For Debug Mode

The target PICmicro MCU must have its configuration words programmed correctly:
- The oscillator configuration bits should correspond to RC, XT, etc., depending upon the target design.
- The target PICmicro MCU must not have the Watchdog Timer enabled.
- The target must not have code protection enabled.
- The target must not have table read protection enabled.

If you enable the DEBUG fuse (with the #device ICD=TRUE statement)
then the CCS compiler will automatically disable the PROTECT fuse and
change it to NOPROTECT instead.
Mortenc



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Thu Jan 31, 2008 2:00 am     Reply with quote

Thanks a lot,

In this case I use the ICD 2 as a programmer. Does this mean that I have to disable the statement #device ICD=TRUE when I use the ICD 2 as a programmer and enable the statement when I use the ICD 2 as a debugger?
Is this the only thing this statement do? (only controling the configuration bits)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 31, 2008 3:05 pm     Reply with quote

Quote:
#device ICD=TRUE

I never have to enter that line. See this thread, where I show how to
use ICD2 with MPLAB to step through a program.
http://www.ccsinfo.com/forum/viewtopic.php?t=33505
I know that it's doing hardware debugging, because when I press the F8
key to single step, I see the busy light on the ICD2 blink for a short time.
I've never used that line and yet I'm able to do hardware debugging
with no problem. Maybe somebody else has a reason why that line
might be needed.
Mortenc



Joined: 22 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Fri Feb 01, 2008 2:56 am     Reply with quote

Thanks for your help.

I will try to debug without this statement next time.

It will then be good if anyone know where this

#device ICD=TRUE

must be used.
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