Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 136
 2012 Microchip Technology Inc.
5.3.5.1
LEGACY SUPPORT FOR PIC18 DEVICES
You may continue to use the PIC18 configuration macros for legacy projects. The com-
piler supports the __CONFIG and __PROG_CONFIG macros which allow configuration 
bit symbols or a configuration word value, respectively, to be specified.
The __CONFIG macro used for PIC18 devices takes an additional argument being the 
number of the configuration word location. For example:
__CONFIG(2, BW8 & PWRTDIS & WDTPS1 & WDTEN);  // specify symbols
or you can specify a literal value if your prefer:
__PROG_CONFIG(1, 0xFE57);    // specify a literal constant value
You cannot use the setting symbols in the __PROG_CONFIG macro, nor can you use a 
literal value in the __CONFIG macro.
The configuration locations do not need to be programmed in order.
Use the pragma in preference to the macros for new projects. To use these macros, 
ensure you include <xc.h> in your source file. Symbols for the macros can be found 
in the .cfgmap files contained in the dat/cfgmap directory of your compiler 
installation.
5.3.5.2
CONFIGURATION CONSIDERATIONS
 Neither the config pragma nor the __CONFIG macro produce executable code. They 
should both be placed outside function definitions so as not to interfere with the 
operation of the function’s code.
MPLAB IDE v8 has a dialog (Config>Configuration bits...) which also allows configura-
tion bits to be specified when the device is programmed. If the check box for “Configu-
ration Bits Set in Code” in this dialog is checked, any configuration bits specified in your 
code using the __CONFIG macro are ignored and those in the dialog used instead. 
Ensure the source of the configuration bit settings is known when working with an 
MPLAB IDE v8 project.
MPLAB X IDE does not allow the configuration bits to be adjusted. They must be spec-
ified in your source code using the pragma (or legacy macro).
All the bits in the configuration words should be programmed to prevent erratic program 
behavior. Do not leave them in their default/unprogrammed state. Not all configuration 
bits have a default state of logic high; some have a logic low default state. Consult your 
device data sheet for more information.