A question about PICMicro configuration.

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
Metalicat
Posts: 5
Joined: Thu Oct 13, 2005 5:16 pm
Contact:

A question about PICMicro configuration.

Post by Metalicat »

When I configure my 16f88 in MPLAB using #fuses, will this override the configuration set in the config screen of PPPv3 Matrix PICmicro programmer?

Or is it the other way around? Will the configuration in the advanced config screen override the #fuses I set in MPLAB?

Ian
Posts: 110
Joined: Thu Sep 29, 2005 10:53 am
Location: Matrix Multimedia
Been thanked: 1 time
Contact:

Post by Ian »

Hex code with embeded config words takes precident over the PPP configuration settings. The PPP settings are used if no embeded config is present. This allows you to test various configs, and to allow fixed configs to be added to final hex code.

Note that __config is prefered to __fuses

the following is taken from ther MPALB help file:


__config - Set Processor Configuration Bits

Note: config is preceded by two underline characters.


Syntax
Preferred:

__config expr
__config addr, expr (PIC18 Only) Note: PIC18FXXJ devices do not support this directive. Use config directive (no underline characters.)

Supported:

__fuses expr
Description
Sets the processor's configuration bits. Before this directive is used, the processor must be declared through the command line, the list directive, the processor directive or Configure>Select Device if using MPLAB IDE. Refer to individual PICmicro microcontroller data sheets for a description of the configuration bits.

PIC10/12/16 MCUs

Sets the processor's configuration bits to the value described by expr.

PIC18 MCUs

For the address of a valid configuration byte specified by addr, sets the configuration bits to the value described by expr.

Note: Configuration bits must be listed in ascending order.


Although this directive may be used to set configuration bits for PIC18 MCU devices, it is recommended that you use the config directive (no underline characters.) For PIC18FXXJ devices, you must use the config directive.

Note: Do not mix __config and config directives in the same code.


Usage
This directive is used in the following types of code: absolute or relocatable. For information on types of code, see Assembler Operation.

This directive is placed in source code so that, when the code is assembled into a hex file, the configuration values are preset to desired values in your application. This is useful when giving your files to a third-party programming house, as this helps insure the device is configured correctly when programmed.

Place configuration bit assignments at the beginning of your code. Use the configuration options (names) in the standard include (*.inc) file. These names can be bitwise ANDed together using & to declare multiple configuration bits.

See Also
config __idlocs list processor
Simple Examples
Example 1: PIC16 Devices
#include p16f877a.inc ;include file with config bit definitions
__config _HS_OSC & _WDT_OFF & _LVP_OFF ;Set oscillator to HS,
;watchdog time off,
;low-voltage prog. off
Example 2: PIC17X Devices
#include p17c42.inc ;include file with config bit definitions
__config 0xFFFF ;default configuration bits
Example 3: PIC18 Devices
#include p18c452.inc ;Include standard header file
;for the selected device.
;code protect disabled.
__CONFIG _CONFIG0, _CP_OFF_0
;Oscillator switch disabled, RC oscillator with OSC2
;as I/O pin.
__CONFIG _CONFIG1, _OSCS_OFF_1 & _RCIO_OSC_1
;Brown-OutReset enabled, BOR Voltage is 2.5v
__CONFIG _CONFIG2, _BOR_ON_2 & _BORV_25_2
;Watch Dog Timer enable, Watch Dog Timer PostScaler
;count - 1:128
__CONFIG _CONFIG3, _WDT_ON_3 & _WDTPS_128_3
;CCP2 pin Mux enabled
__CONFIG _CONFIG5, _CCP2MX_ON_5
;Stack over/underflow Reset enabled
__CONFIG _CONFIG6, _STVR_ON_6

Post Reply