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
Edit from Moderator:
A Wiki for this thread has been created, making a somewhat condensed version of this thread. It is located here: http://www.picbasic.co.uk/forum/cont...o-your-Program
Bookmarks