Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

Device-Related Features
2012-2013 Microchip Technology Inc. DS50002071C-page 109
6.5 CONFIGURATION BIT ACCESS
Microchip devices have several locations which contain the configuration bits or fuses.
These bits specify fundamental device operation, such as the oscillator mode, watch-
dog timer, programming mode and code protection. Failure to correctly set these bits
may result in code failure or a non-running device.
6.5.1 Configuration Settings Using #pragma config
Configuration Settings may be made using the preprocessor directive #pragma
config and settings macros specified under the docs subdirectory of the compiler
install directory.
The directive format options are:
#pragma config setting = state|value
#pragma config register = value
where setting is a configuration setting descriptor (e.g., WDT), state is a descrip-
tive value (e.g., ON) and value is a numerical value. The register token may represent
a whole configuration word register, e.g., CONFIG1L.
A list of all available settings by device may be found from MPLAB X IDE, Dashboard
window, Compiler Help button or from the command-line under:
<MPLAB XC16 Installation folder>/vx.xx/docs/config_index.html
6.5.2 Configuration Settings Using Macros
Configuration Settings macros are provided that can be used to set configuration bits.
For example, to set the FOSC bit using a macro, the following line of code can be
inserted before the beginning of your C source code:
_FOSC(CSW_FSCM_ON & EC_PLL16);
This would enable the external clock with the PLL set to 16x and enable clock switching
and fail-safe clock monitoring.
Similarly, to set the FBORPOR bit:
_FBORPOR(PBOR_ON & BORV_27 & PWRT_ON_64 & MCLR_DIS);
This would enable Brown-out Reset at 2.7 Volts and initialize the Power-up timer to 64
milliseconds and configure the use of the MCLR
pin for I/O.
Configuration Settings macros are defined in compiler header files for each device.
Please refer to your devices header files for a complete listing of related macros.
Header files are located, by default, in:
<MPLAB XC16 Installation folder>/vx.xx/support/device/h
where vx.xx is the compiler version and device is your 16-bit device family.
6.6 USING SFRS
The Special Function Registers (SFRs) are registers which control aspects of the MCU
operation or that of peripheral modules on the device. These registers are device mem-
ory mapped, which means that they appear at, and can be accessed using, specific
addresses in the devices data memory space. Individual bits within some registers
control independent features. Some registers are read-only; some are write-only. See
your device data sheet for more information.
Memory-mapped SFRs are accessed by special C variables that are placed at the
address of the register. These variables can be accessed like any ordinary C variable
so that no special syntax is required to access SFRs.

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh