Each attribute in the configuration table below has two or more possible values associated with it.
e.g. the watchdog attribute (labelled field F ) has the possible values
one and only one of these values must be specified when configuring the CPU
- CFG_WDT_ON
- CFG_WDT_OFF
The 16f628 CPU has 8 configuration attributes (labelled field A to H in the table below). The attributes specific to the 16f628 CPU are defined in the file hwreg-p16f628.h To correctly configure the 16f628 CPU each attribute must be set to a valid value. This is done by using one "pragma cpu_config" statement per attribute. A valid configuration for 16f628 would look like:
e.g. include "hwreg-p16f628.h" pragma cpu_config CFG_CP_ALL pragma cpu_config CFG_DATA_CP_ON pragma cpu_config CFG_BODEN_ON pragma cpu_config CFG_MCLRE_ON pragma cpu_config CFG_PWRTE_ON pragma cpu_config CFG_WDT_ON pragma cpu_config CFG_LVP_ON pragma cpu_config CFG_ER_OSC_CLKOUTNOTE: All attributes for a given processor must be specified, attributes for different processors may not be mixed.
Field Attribute XCSB value Description A Program Memory Code Protect CFG_CP_ALL code protect all program memory CFG_CP_75 code protect top 75% of program memory CFG_CP_50 code protect top 50% of program memory CFG_CP_OFF do not code protect any program memory B Data Memory Code Protected CFG_DATA_CP_ON data memory is code protected CFG_DATA_CP_OFF data memory is NOT code protected C Brown-Out Detect CFG_BODEN_ON Brown-Out Detect enabled CFG_BODEN_OFF Brown-Out Detect disabled D RA5/MCLR pin function select CFG_MCLRE_ON RA5/MCLR pin is MCLR function CFG_MCLRE_OFF RA5/MCLR pin is digital I/O function
(MCLR is internally tied to VDD)E Power-Up Timer CFG_PWRTE_ON power-up timer enable CFG_PWRTE_OFF power-up timer disable F Watchdog timer CFG_WDT_ON watchdog timer enable CFG_WDT_OFF watchdog timer disable G Low Voltage In-Circuit Programming CFG_LVP_ON Low Voltage in-circuit serial Programming enabled
RB4/PGM pin has PGM functionCFG_LVP_OFF Low Voltage in-circuit serial Programming disabled
RB4/PGM pin has digital I/O function
(high voltage must be present on MCLR pin for programming)H Oscillator CFG_ER_OSC_CLKOUT External Resistor (ER) oscillator
with clock output
RA6/OSC2/CLKOUT pin is CLKOUT function
resister on RA7/OSC1/CLKIN pinCFG_ER_OSC_NOCLKOUT External Resistor (ER) oscillator
without clock output
RA6/OSC2/CLKOUT pin is I/O function
resister on RA7/OSC1/CLKIN pinCFG_INTRC_OSC_CLKOUT Internal Resistor / Capacitor (INTRC) oscillator
with clock output
RA6/OSC2/CLKOUT pin is CLKOUT function
RA7/OSC1/CLKIN pin is I/O functionCFG_INTRC_OSC_NOCLKOUT Internal Resistor / Capacitor (INTRC) oscillator
without clock output
RA6/OSC2/CLKOUT pin is I/O function
RA7/OSC1/CLKIN pin is I/O functionCFG_EXTCLK_OSC External Clock (EC)
RA6/OSC2/CLKOUT pin is I/O function
RA7/OSC1/CLKIN pin is CLKIN functionCFG_HS_OSC High Speed Crystal / Resonator (HS) oscillator CFG_XT_OSC Crystal / Resonator (XT) oscillator CFG_LP_OSC Low Power Crystal (LP) oscillator