Microchip Technology SW006021-1N Manual Do Utilizador
MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 48
2012 Microchip Technology Inc.
3.4.2
Device-Specific Features
This section discusses the code that needs to be written to set up or control a feature
that is specific to Microchip PIC devices.
that is specific to Microchip PIC devices.
3.4.2.1
HOW DO I SET THE CONFIGURATION BITS?
These should be set in your code using either a macro or pragma. Earlier versions of
MPLAB IDE allowed you to set these bits in a dialog, but MPLAB X IDE requires that
they be specified in your source code. See Section 5.3.5 “Configuration Bit Access”
for how these are set.
MPLAB IDE allowed you to set these bits in a dialog, but MPLAB X IDE requires that
they be specified in your source code. See Section 5.3.5 “Configuration Bit Access”
for how these are set.
3.4.2.2
HOW DO I USE THE PIC’S ID LOCATIONS?
There is a supplied macro or pragma that allows these values to be programmed, see
Section 5.3.7 “ID Locations”.
Section 5.3.7 “ID Locations”.
3.4.2.3
HOW DO I DETERMINE THE CAUSE OF RESET ON MID-RANGE
PARTS?
PARTS?
The TO and PD bits in the STATUS register allow you to determine the cause of a
Reset. However, these bits are quickly overwritten by the runtime startup code that is
executed before main is executed, see Section 5.10.1 “Runtime Startup Code”. You
can have the STATUS register saved into a location that is later accessible from C code
so that the cause of Reset can be determined by the application once it is running
again. See Section 5.10.1.4 “STATUS Register Preservation”.
Reset. However, these bits are quickly overwritten by the runtime startup code that is
executed before main is executed, see Section 5.10.1 “Runtime Startup Code”. You
can have the STATUS register saved into a location that is later accessible from C code
so that the cause of Reset can be determined by the application once it is running
again. See Section 5.10.1.4 “STATUS Register Preservation”.
3.4.2.4
HOW DO I ACCESS SFRS?
The compiler ships with header files, see Section 5.3.3 “Device Header Files”, that
define variables which are mapped over the top of memory-mapped SFRs. Since these
are C variables, they can be used like any other C variable and no new syntax is
required to access these registers.
define variables which are mapped over the top of memory-mapped SFRs. Since these
are C variables, they can be used like any other C variable and no new syntax is
required to access these registers.
Bits within SFRs can also be accessed. Individual bit-wide variables are defined which
are mapped over the bits in the SFR. Bit-fields are also available in structures which
map over the SFR as a whole. You can use either in your code. See Section 5.3.6
“Using SFRs From C Code”.
are mapped over the bits in the SFR. Bit-fields are also available in structures which
map over the SFR as a whole. You can use either in your code. See Section 5.3.6
“Using SFRs From C Code”.
The name assigned to the variable is usually the same as the name specified in the
device data sheet. See Section 3.4.2.5 “How Do I Find The Names Used to Repre-
sent SFRs and Bits?” if these names are not recognized.
device data sheet. See Section 3.4.2.5 “How Do I Find The Names Used to Repre-
sent SFRs and Bits?” if these names are not recognized.