Fuse Settings

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
MarkW
Posts: 73
Joined: Fri Oct 27, 2006 8:09 pm

Fuse Settings

Post by MarkW » Fri Oct 27, 2006 8:13 pm

How do I configure fuse settings in SF? I tried the way I've been doing it in Picbasic Pro but can't seem to get it to work. I have just started playing with a 18F1320 for practice and would like to set the osc type etc.
Thanks

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Fri Oct 27, 2006 8:32 pm

The documentation on this is a little lacking. I will try and get something on the wiki soon. Anyway, here is a crash course...

A useful technique to see what fuse settings are available for your particular device is to open the swordfish device system file. For example, if your program has

Code: Select all

device = 18F1320
then just click on the '18F1320' node in the explorer window to open the file. If you scroll down, you will see the following

Code: Select all

// configuration fuses...
public config
   OSC(OSC) = [LP, XT, HS, EC, ECIO, HSPLL, RCIO, INTIO2, INTIO1, RC],
   FSCM(FSCM) = [OFF, ON],
   IESO(IESO) = [OFF, ON],
   PWRT(PWRT) = [ON, OFF],
   BOR(BOR) = [OFF, ON],
   BORV(BORV) = [45, 42, 27, 20],
   WDT(WDT) = [OFF, ON],
   WDTPS(WDTPS) = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],
   MCLRE(MCLRE) = [OFF, ON],
   STVR(STVR) = [OFF, ON],
   LVP(LVP) = [OFF, ON],
   DEBUG(DEBUG) = [ON, OFF],
   CP0(CP0) = [ON, OFF],
   CP1(CP1) = [ON, OFF],
   CPB(CPB) = [ON, OFF],
   CPD(CPD) = [ON, OFF],
   WRT0(WRT0) = [ON, OFF],
   WRT1(WRT1) = [ON, OFF],
   WRTB(WRTB) = [ON, OFF],
   WRTC(WRTC) = [ON, OFF],
   WRTD(WRTD) = [ON, OFF],
   EBTR0(EBTR0) = [ON, OFF],
   EBTR1(EBTR1) = [ON, OFF],
   EBTRB(EBTRB) = [ON, OFF]
These are the options available to you. Lets take one example, OSC.

Code: Select all

   OSC(OSC) = [LP, XT, HS, EC, ECIO, HSPLL, RCIO, INTIO2, INTIO1, RC]
You can see a little further down that the 'default' has been set to HS

Code: Select all

// default fuses...
config
   OSC = HS,
   IESO = OFF,
   PWRT = ON,
   BOR = ON,
   BORV = 20,
   WDT = OFF,
   WDTPS = 128,
   STVR = ON,
   LVP = OFF,
   DEBUG = OFF
So if you build you program, the above default setting will be used. You don't need to set them again. To change a fuse setting, just use the config keyword in your program. For example,

Code: Select all

device = 18F1320
config
   OSC = HSPLL,
   BOR = OFF
include "usart.bas"
...
In the above example, OSC has now been set to HSPLL and BOR has been disabled. As you can see, you just simply override the settings in your program. You don't need any ASM or have to edit the system file.

Jack Smith has been posting a DDS article on the wiki. If you scroll down the page, you will see some sample code and detailed explanations on setting the configuration fuses using swordfish...

http://www.sfcompiler.co.uk/wiki/pmwiki ... shUser.DDS

MarkW
Posts: 73
Joined: Fri Oct 27, 2006 8:09 pm

Thanks

Post by MarkW » Mon Oct 30, 2006 1:35 pm

David,
Thanks for the reply. Excatly what I needed to continue playing.

Post Reply