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

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



Joined: 18 Dec 2007
Posts: 86

View user's profile Send private message Send e-mail

Fuses
PostPosted: Tue Jul 14, 2026 4:56 am     Reply with quote

IDE 5.121
PCB 5.121
PCM 5.121
Fuses of the 4 config locations don't agree with the #Fuses command.


#include <16F18323.H>
#Fuses RSTOSC_HFINTRC_PLL,NOCLKOUT,NOEXTOSC,NOCKS,NOMCLR,PUT,NOWDT,BROWNOUT,BORV27,NOPPS1WAY,STVREN,NODEBUG,NOWRT,NOLVP,PROTECT,NOFCMEN

If I read/check the Configuration/ID settings in the CCS Device Programmer (CCS load) I see the following:
Config "1" = 1FEC
Config "2" = 35F0
Config "3" = 1FFF
Config "4" = 3FFE
The comment at the left tells me:
The "ON Power-up clock running from HFINTRC at 1MHz".
And the "clock switching enabled"" box is marked.


Can somebody help me to change the #Fuse settings in the C-file to get the following settings according the CCS Device Programmer windown?

Config "1" = 178C
Config "2" = 35F0
Config "3" = 1FFF
Config "4" = 3FFE


Thank you.
jeremiah



Joined: 20 Jul 2010
Posts: 1424

View user's profile Send private message

PostPosted: Tue Jul 14, 2026 7:39 am     Reply with quote

You can use the #fuses directive. It has 3 main uses:

Code:

#fuses DEBUG      // sets the debug configuration bit individually
#fuses 1=0x1FEC // sets all the bits in config word 1 at one time
#fuses none       // Makes sure no config bits are set, useful for apps being bootloaded



Most of us use the first method as it is more readable, less error prone, and gives you granular control on all the fuses. Here's an example of my settings from one of my projects:

Code:

#include <16F15325.h>

#fuses NOCLKOUT              //I/O function on OSC2
#fuses MCLR                  //Master Clear pin enabled
#fuses NOPUT                 //No Power Up Timer
#fuses LPBOR                 //Low-Power Brownout reset is enabled
#fuses BROWNOUT              //Reset when brownout detected
#fuses ZCDDIS                //Zero-cross detect circuit is disabled at POR
#fuses STVREN                //Stack full/underflow will cause reset
#fuses NODEBUG               //No Debug mode for ICD
#fuses WDT8388608            //Watch Dog Timer uses 1:8388608 Postscale
#fuses WDT_NOSL              //Watch Dog Timer, disabled during SLEEP
#fuses WDTWIN_SW             //Watchdog Window is settable in software
#fuses WDTCLK_LFINTRC        //WDT uses 31.0 kHz LFINTRC as clock source
#fuses NOBOOTBLOCK           //Boot Block disabled
#fuses NOSAF                 //Storage Area Flash disabled
#fuses NOWRT                 //Program memory not write protected
#fuses NOWRTB                //Boot block not write protected
#fuses NOWRTC                //Configuration registers not write protected
#fuses NOWRTSAF              //Storage Area Flash not write protected
#fuses NOLVP                 //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#fuses NOPROTECT             //Code not protected from reading

// Setup the clock
#pragma use delay(internal=32000000)


You can open up a dialog in the IDE to see all the available config bit settings and even copy them (to be pasted in your code).

BUT if you truly do want to set them all at once, use the 2nd method I mentioned.


Last edited by jeremiah on Wed Jul 15, 2026 7:31 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 20108

View user's profile Send private message

PostPosted: Tue Jul 14, 2026 11:17 am     Reply with quote

He doesn't need to do that.
The big problem is he is selecting the wrong clock fuse. However easier, just
let the compiler set it for you:

Code:

#use delay(internal=32M)
#fuses NOGCMEN, NOMCLR, PROTECT


Should give the pattern he wants.
Most of the fuses default to what he is trying to set.
temtronic



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

View user's profile Send private message

PostPosted: Tue Jul 14, 2026 11:48 am     Reply with quote

when I started using the 46k22, I created a fuses46kbase.h file.
one fuse per line
'base' file settings confirm the PIC and PCB actually work ( 'Hello World' on LCD, flashing 1HZ LED )

then 'include' it .

solved 2 problems
1) main got smaller and easier to read
2) far less typos !

when projects need different fuse settings than the 'base', , I copy/edit/save changing 'base' to 'project name'
Ttelmah



Joined: 11 Mar 2010
Posts: 20108

View user's profile Send private message

PostPosted: Tue Jul 14, 2026 12:23 pm     Reply with quote

and the first thing in my fuses line should be NOFC not NOGC. Mistyped.
temtronic



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

View user's profile Send private message

PostPosted: Tue Jul 14, 2026 2:18 pm     Reply with quote

probably take me 3 for 4 retypes to get it right......
getting old is so much fun !
bschriek



Joined: 18 Dec 2007
Posts: 86

View user's profile Send private message Send e-mail

PostPosted: Wed Jul 15, 2026 3:37 am     Reply with quote

Dear Jeremiah,

I like your suggestion: #fuses 1 = 0x1F8C // sets all the bits in config word 1 at one time.


However I got the following error:....... Line 30(7,68): Unknown keyword in #FUSES "0X1F8C"


Anny suggestion?
temtronic



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

View user's profile Send private message

PostPosted: Wed Jul 15, 2026 5:53 am     Reply with quote

hmm... maybe get rid of the quotes ?
jeremiah



Joined: 20 Jul 2010
Posts: 1424

View user's profile Send private message

PostPosted: Wed Jul 15, 2026 7:32 am     Reply with quote

bschriek wrote:
Dear Jeremiah,

I like your suggestion: #fuses 1 = 0x1F8C // sets all the bits in config word 1 at one time.


However I got the following error:....... Line 30(7,68): Unknown keyword in #FUSES "0X1F8C"


Anny suggestion?


I updated the answer above, but take out the spaces around the equals sign:
Code:
 #fuses 1=0x1FEC
Ttelmah



Joined: 11 Mar 2010
Posts: 20108

View user's profile Send private message

PostPosted: Wed Jul 15, 2026 11:15 pm     Reply with quote

Possibly just worth making a comment here.
All fuses are set to '1' by default. This is inherent in the memory cells
involved. Now for some fuses '1' is the off state, while for others this is
the on state. So to get a particular fuse pattern, what you have to do
is look in the data sheet and work out which bits need to be set to 0
for the pattern required. This is why many of the fuse settings shown
in the poster's original list are not needed, since they are already set.
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