View previous topic :: View next topic |
Author |
Message |
Mortenc
Joined: 22 Feb 2007 Posts: 55
|
#fuses - set in code don´t seems to work |
Posted: Wed Jan 30, 2008 9:33 am |
|
|
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
|
|
Posted: Wed Jan 30, 2008 9:55 am |
|
|
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
|
|
Posted: Wed Jan 30, 2008 2:46 pm |
|
|
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
|
|
Posted: Wed Jan 30, 2008 5:06 pm |
|
|
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
|
|
Posted: Thu Jan 31, 2008 2:00 am |
|
|
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
|
|
Posted: Thu Jan 31, 2008 3:05 pm |
|
|
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
|
|
Posted: Fri Feb 01, 2008 2:56 am |
|
|
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. |
|
|
|