Presetting Configuration Fuses (PIC Defines) into your Program
1. What are the Configuration Fuses?
2. How can I preset them in my Program?
2.a. When using MeLabs default (PM) Assembler
2.b. When using Microchip's (MPASM) Assembler
3. Where can I find a List of the Configuration Definitions?
3.a. When using MeLabs default (PM) Assembler
3.b. When using Microchip's (MPASM) Assembler
1. What are the Configuration Fuses?
The Configuration Fuses (Configuration Bits) are the settings that configure the PIC for the external environment it is expecting to find... typical settings include Oscillator Type, MCLR pin usage, Code Protection, Brown-Out and Watchdog Timer usage, Low Voltage Programming etc. Different families of PICs have different settings, so the list of settings for a 12F675, will not be the same as the list for a 16F877. When you LOAD a program into your programmer, these settings appropriately configure it without you having to make any additional changes. This saves you a lot of time messing with minor settings before you hit the 'Program' Button. Remember though, you are still able to over-ride these setting manually prior to programming your chip. Most programmers will only configure the settings to your compiled defaults when you LOAD the program, so if you change them manually, you will need to RELOAD your program for them to revert to the default (compiled) settings.
2. How can I preset them in my Program?
This very much depends on if you are using MeLabs default (PM) Assembler, or Microchips (MPASM) alternative.
2.a. When using MeLabs default (PM) Assembler
Example: To set the PIC for XT Oscillator...
@ DEVICE XT_OSC
or
@ DEVICE PIC16F628,XT_OSC
The PIC type is optional, if it is included and you accidentally compile for a chip other than that specified (a 16F628 in this example), the compiler will report an error as a reminder you're potentially doing something wrong.
Multiple definitions are entered on separate lines, one line per definition and can be interspersed with comments…
Example: Typical Settings for a 16F628…
@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F628, WDT_ON
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_ON
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
' Set to CPD_ON for Release Copy
@ DEVICE pic16F628, PROTECT_ON
' Program Code Protection
' Set to PROTECT_OFF for Development Copy
' Set to PROTECT_ON for Release Copy
2.b. When using Microchip's (MPASM) Assembler
Example: To set the PIC for Internal Oscillator allowing use of the OSC pins as I/O...
@ __config _INTRC_OSC_NOCLKOUT
Only one config statement is allowed when using MPASM, so multiple definitions follow-on from each other each connected to it’s previous buddy with an &.
Example: Typical Settings for a 16F628…
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _LVP_OFF & _CP_ALL & _DATA_CP_ON
3. Where can I find a List of the Configuration Definitions?
Now you’ll have noticed that my multiple example for PM and MPASM above are for the same configuration settings (they are now, they weren't when first posted!) - you’ll notice however that there are differences… MCLR_OFF in PM becomes MCLRE_OFF when using MPASM… Here’s how you find the list of possible options available to you… whether you chose to use the default PM or the option of the MPASM Assembler, cross-reference your choices with your chosen PICs Datasheet, look in the section entitled “Special Features of the CPU”. Some configurations may be listed under multiple names, the little extra being provided for your convenience.
3.a. When using MeLabs default (PM) Assembler
Open up the PBP directory, and in it you will find an INC subdirectory. Opening that up and you'll see a heap of files. Find the Mxxxx.INC file for the PIC you're interested in... (example M12F675.INC). If you can’t locate your exact PIC, it might be listed under a family of PICs that share the same settings (example chose M16F62X.INC if you need the settings for a 16F628). Open the file up with something like Notepad – (don’t make any changes to it) and have a look what the file contains…It reveals the internal sex life of the PIC. All the Configuration Fuse Defines that you can use from within PBP are listed here at the top, and lower down all the Registers are Listed. If it's not in the list, you can't use it - but trust me, it's usually all there. Remember, this list is for use with the PM (default assembler).
3.b. When using Microchip's (MPASM) Assembler
If you're going to use MPASM, look for the appropriate file (example for a 16F628 look for P16F628.INC) located in something like the MCHIP_Tools subdirectory of your MPLAB installation. Here you’ll find the Configuration Bits located near the bottom of the list. Simply just use the ones you want. Hey presto your PIC is all defined and ready to run.
Melanie
Warning[230] __CONFIG has been deprecated for PIC18 devices.
If you are using any PIC18 serie, you will have this warning one day or another. Our friends from Microchip decide to change the way to define the config fuses when using the latest MPASM version 5.00.
The solution is still located at the same place... at the end of the 18XXXX.INC file located in the MPASM folder.
Quote:
Originally Posted by Snip of MPASM 18F452.INC
; IMPORTANT: For the PIC18 devices, the __CONFIG directive has been
; superseded by the CONFIG directive. The following settings
; are available for this device.
;
; Oscillator Selection:
; OSC = LP LP
; OSC = XT XT
; OSC = HS HS
; OSC = RC RC
; OSC = EC EC-OSC2 as Clock Out
; OSC = ECIO EC-OSC2 as RA6
; OSC = HSPLL HS-PLL Enabled
; OSC = RCIO RC-OSC2 as RA6
SO now the new method to set the config fuse on the PIC18 serie is...
Code:
@ CONFIG OSCS=OFF, OSC=HS
' Oscillator switch OFF
' Use HS oscillator (20MHZ here)
'
@ CONFIG BOR=ON, PWRT=ON, BORV=45
' Brown out reset ON @ 4.5Volts
' Power-up timer ON
'
@ CONFIG WDT=ON
' Watch dog timer ON
'
@ CONFIG STVR=ON, LVP=OFF, DEBUG=OFF
' Stack over/underflow ON
' Low Voltage programming OFF
' Background debugger OFF
Or if you prefer...
Code:
ASM
CONFIG OSCS=OFF ; Oscillator switch OFF
CONFIG OSC=HS ; Use HS oscillator (20MHZ here)
CONFIG BOR=ON ; Brown out reset ON
CONFIG BORV=45 ; Brown out detect voltage=4.5 Volt
CONFIG PWRT=ON ; Power-up timer ON
CONFIG WDT=ON ; Watch dog timer ON
CONFIG STVR=ON ; Stack over/underflow ON
CONFIG LVP=OFF ; Low Voltage programming OFF
CONFIG DEBUG=OFF ; Background debugger OFF
ENDASM
Don't forget to comment the default PBP config fuses...
Warning[230]c:\...\..:__CONFIG has been deprecated for PIC1
Quote:
Originally Posted by Tissy
Thanks for that. I thought i was going mad !! Theres nothing worse than people saying it should work when it doesn't. You have save my insanity.
I think the .CFG approach is a good solution.
Many thanks,
Steve
hi,
i also facing similar problem if i try to compile programe on 18f452 i get the similar message like:
Warning[230]c:\develo~1\susdco~1\rfusb~1.asm 67:__CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
i am using pbp2.44 with mpasm7.21.
I tried to rectify the problems with the above directives but fail should i go for the other version of mplab
pl. help
thanks
Warning[230]: __CONFIG has been deprecated ...
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
If using 18F Parts...
Check this answer by Bruce...
http://www.picbasic.co.uk/forum/showthread.php?p=13087
... if you're not using 18F Parts and you're getting this message - you're in deep trouble.
Can you make a short papra of what to do....
I am really confused from the thread. It has many different approaches. I am using picbasic pro 2.45 and Mpasm of mplab v7.22. I get the same error.
:__CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
So, how can i set my configuration bits??? I am using 18f4520.
PBC Options for Fuse Setting
Quote:
So in PBC NOT pro there is no @ DEVICE command so I assume there is another way to set fuses and pin defaults or is it only done in the programmer itself? ...
PIC BASIC COMPILER USERS (PBC), see this thread for some options on presetting fuses
http://www.picbasic.co.uk/forum/showthread.php?t=4158
(don't let the name of the thread fool you, what you want is toward the bottom)
Paul Borgmeier
Salt Lake City, Utah
USA