Microchip Technology SW006022-2N Data Sheet
MPLAB
®
XC16 C COMPILER
USER’S GUIDE
2012 Microchip Technology Inc.
DS52071B-page 305
Appendix G. XC16 Configuration Settings
G.1
INTRODUCTION
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:
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.
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.
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 device’s header files for a complete listing of related macros.
Header files are located, by default, in:
Please refer to your device’s header files for a complete listing of related macros.
Header files are located, by default, in:
C:\Program Files\Microchip\mplabxc16\v1.0\support\device\h
where device is the 16-bit device family you are using.
EXAMPLE G-1:
P33FJ128MC510.H HEADER FILE - FWDT REGISTER
/*-----------------------------------------------------------------
* MPLAB-Cxx dsPIC33FJ128MC510 processor header
*
* (c) Copyright 1999-2010 Microchip Technology, All rights reserved
*-----------------------------------------------------------------*/
:
:
/* Register FWDT (0xf8000a) */
extern __attribute__((space(prog))) int _FWDT;
#define _FWDT(x) __attribute__((section("__FWDT.sec"),space(prog)))
int _FWDT = (x);
/*
** Only one invocation of FWDT should appear in a project,
** at the top of a C source file (outside of any function).
**
** The following constants can be used to set FWDT.
** Multiple options may be combined, as shown:
**
** _FWDT( OPT1_ON & OPT2_OFF & OPT3_PLL )
**
** Watchdog Timer:
** FWDTEN_OFF Disabled
** FWDTEN_ON Enabled
**
** Windowed WDT:
** WINDIS_ON Enabled