You are on page 1of 7

1. What are the Configuration Fuses?

2. How can I preset them in my Program?


2.a. When using MeLabs default (PM) Assembler
2.b. When using Microchip's (MPASM) Assembler
3. Where can I find a List of the Configuration Definitions?
3.a. When using MeLabs default (PM) Assembler
3.b. When using Microchip's (MPASM) Assembler

1. What are the Configuration Fuses?

The Configuration Fuses (Configuration Bits) are the settings that configure the
PIC for the external environment it is expecting to find... typical settings include
Oscillator Type, MCLR pin usage, Code Protection, Brown-Out and Watchdog
Timer usage, Low Voltage Programming etc. Different families of PICs have
different settings, so the list of settings for a 12F675, will not be the same as
the list for a 16F877. When you LOAD a program into your programmer, these
settings appropriately configure it without you having to make any additional
changes. This saves you a lot of time messing with minor settings before you
hit the 'Program' Button. Remember though, you are still able to over-ride
these setting manually prior to programming your chip. Most programmers will
only configure the settings to your compiled defaults when you LOAD the
program, so if you change them manually, you will need to RELOAD your
program for them to revert to the default (compiled) settings.

2. How can I preset them in my Program?

This very much depends on if you are using MeLabs default (PM) Assembler, or
Microchips (MPASM) alternative.

2.a. When using MeLabs default (PM) Assembler

Example: To set the PIC for XT Oscillator...

@ DEVICE XT_OSC

or

@ DEVICE PIC16F628,XT_OSC

The PIC type is optional, if it is included and you accidentally compile for a chip
other than that specified (a 16F628 in this example), the compiler will report an
error as a reminder you're potentially doing something wrong.

Multiple definitions are entered on separate lines, one line per definition and can
be interspersed with comments…
Example: Typical Settings for a 16F628…

@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT


' System Clock Options
@ DEVICE pic16F628, WDT_ON
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_ON
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
' Set to CPD_ON for Release Copy
@ DEVICE pic16F628, PROTECT_ON
' Program Code Protection
' Set to PROTECT_OFF for Development Copy
' Set to PROTECT_ON for Release Copy

2.b. When using Microchip's (MPASM) Assembler

Example: To set the PIC for Internal Oscillator allowing use of the OSC pins as
I/O...

@ __config _INTRC_OSC_NOCLKOUT

Only one config statement is allowed when using MPASM, so multiple definitions
follow-on from each other each connected to it’s previous buddy with an &.

Example: Typical Settings for a 16F628…

@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON &


_MCLRE_OFF & _BODEN_ON & _LVP_OFF & _CP_ALL & _DATA_CP_ON

3. Where can I find a List of the Configuration Definitions?

Now you’ll have noticed that my multiple example for PM and MPASM above are
for the same configuration settings (they are now, they weren't when first
posted!) - you’ll notice however that there are differences… MCLR_OFF in PM
becomes MCLRE_OFF when using MPASM… Here’s how you find the list of
possible options available to you… whether you chose to use the default PM or
the option of the MPASM Assembler, cross-reference your choices with your
chosen PICs Datasheet, look in the section entitled “Special Features of the
CPU”. Some configurations may be listed under multiple names, the little extra
being provided for your convenience.

3.a. When using MeLabs default (PM) Assembler

Open up the PBP directory, and in it you will find an INC subdirectory. Opening
that up and you'll see a heap of files. Find the Mxxxx.INC file for the PIC you're
interested in... (example M12F675.INC). If you can’t locate your exact PIC, it
might be listed under a family of PICs that share the same settings (example
chose M16F62X.INC if you need the settings for a 16F628). Open the file up
with something like Notepad – (don’t make any changes to it) and have a look
what the file contains…It reveals the internal sex life of the PIC. All the
Configuration Fuse Defines that you can use from within PBP are listed here at
the top, and lower down all the Registers are Listed. If it's not in the list, you
can't use it - but trust me, it's usually all there. Remember, this list is for use
with the PM (default assembler).

3.b. When using Microchip's (MPASM) Assembler

If you're going to use MPASM, look for the appropriate file (example for a
16F628 look for P16F628.INC) located in something like the MCHIP_Tools
subdirectory of your MPLAB installation. Here you’ll find the Configuration Bits
located near the bottom of the list. Simply just use the ones you want. Hey
presto your PIC is all defined and ready to run.

1. ¿Qué son los fusibles de configuración?

2. ¿Cómo puedo preestablecerlos en mi programa?

2.a. Cuando se usa el ensamblador predeterminado (PM) de MeLabs

2.b. Cuando se utiliza el ensamblador de Microchip (MPASM)

3. ¿Dónde puedo encontrar una lista de las definiciones de configuración?

3.a. Cuando se usa el ensamblador predeterminado (PM) de MeLabs

3.b. Cuando se utiliza el ensamblador de Microchip (MPASM)

1. ¿Qué son los fusibles de configuración?

Los fusibles de configuración (bits de configuración) son los ajustes que configuran el PIC para el
entorno externo que espera encontrar ... los ajustes típicos incluyen el tipo de oscilador, el uso del
pin MCLR, la protección del código, el uso del temporizador de apagado y vigilancia, la
programación de bajo voltaje etc. Las diferentes familias de PIC tienen configuraciones diferentes,
por lo que la lista de configuraciones para un 12F675 no será la misma que la lista para un 16F877.
Cuando CARGAS un programa en tu programador, estas configuraciones lo configuran
adecuadamente sin que tengas que hacer ningún cambio adicional. Esto le ahorra mucho tiempo
jugando con configuraciones menores antes de presionar el botón 'Programa'. Sin embargo,
recuerde que aún puede anular esta configuración manualmente antes de programar su chip. La
mayoría de los programadores solo configurarán los ajustes a sus valores predeterminados
compilados cuando CARGUE el programa, por lo que si los cambia manualmente, deberá
RECARGAR su programa para que vuelvan a la configuración predeterminada (compilada).

2. ¿Cómo puedo preestablecerlos en mi programa?

Esto depende en gran medida de si está utilizando el ensamblador predeterminado de MeLabs


(PM) o la alternativa Microchips (MPASM).

2.a. Cuando se usa el ensamblador predeterminado (PM) de MeLabs

Ejemplo: para configurar el PIC para el oscilador XT ...

@ DISPOSITIVO XT_OSC

@ DISPOSITIVO PIC16F628, XT_OSC

El tipo PIC es opcional, si está incluido y compila accidentalmente un chip diferente al especificado
(un 16F628 en este ejemplo), el compilador informará un error como un recordatorio de que
potencialmente está haciendo algo mal.
Se ingresan varias definiciones en líneas separadas, una línea por definición y se pueden intercalar
con comentarios ...

Ejemplo: ajustes típicos para un 16F628 ...

@ DISPOSITIVO pic16F628, INTRC_OSC_NOCLKOUT

'Opciones de reloj del sistema

@ DISPOSITIVO pic16F628, WDT_ON

' Temporizador de vigilancia

@ DISPOSITIVO pic16F628, PWRT_ON

'Temporizador de encendido

@ DISPOSITIVO pic16F628, MCLR_OFF

'Opciones de borrado maestro (interno)

@ DISPOSITIVO pic16F628, BOD_ON

Detección de oscurecimiento

@ DISPOSITIVO pic16F628, LVP_OFF

'Programación de bajo voltaje

@ DISPOSITIVO pic16F628, CPD_ON

'Protección de código de memoria de datos

'Establecer en CPD_OFF para la copia de desarrollo

'Establecer en CPD_ON para la copia de lanzamiento

@ DISPOSITIVO pic16F628, PROTECT_ON

'Protección del código del programa

'Establecer en PROTECT_OFF para la copia de desarrollo

'Establecer en PROTECT_ON para la Copia de lanzamiento

2.b. Cuando se utiliza el ensamblador de Microchip (MPASM)


Ejemplo: para configurar el PIC para el oscilador interno que permite el uso de los pines OSC como
E / S ...

@ __config _INTRC_OSC_NOCLKOUT

Solo se permite una declaración de configuración cuando se usa MPASM, por lo que varias
definiciones se suceden entre sí, cada una conectada a su amigo anterior con un &.

Ejemplo: ajustes típicos para un 16F628 ...

@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
& _LVP_OFF & _CP_ALL & _DATA_CP_ON

3. ¿Dónde puedo encontrar una lista de las definiciones de configuración?

Ahora te habrás dado cuenta de que mi ejemplo múltiple para PM y MPASM anteriores son para
los mismos ajustes de configuración (¡ahora son, no estaban cuando se publicaron por primera
vez!); Sin embargo, notarás que hay diferencias ... MCLR_OFF en PM se convierte en MCLRE_OFF
cuando se usa MPASM ... A continuación, le mostramos cómo encontrar la lista de posibles
opciones disponibles ... ya sea que elija usar el PM predeterminado o la opción del ensamblador
MPASM, haga una referencia cruzada de sus opciones con la hoja de datos de PIC elegida, consulte
la sección titulada "Características especiales de la CPU". Algunas configuraciones se pueden
enumerar bajo varios nombres, proporcionándose el pequeño extra para su conveniencia.

3.a. Cuando se usa el ensamblador predeterminado (PM) de MeLabs

Abra el directorio PBP, y en él encontrará un subdirectorio INC. Al abrir eso, verás un montón de
archivos. Encuentre el archivo Mxxxx.INC para el PIC que le interesa ... (ejemplo M12F675.INC). Si
no puede ubicar su PIC exacto, puede aparecer en una familia de PIC que comparten la misma
configuración (por ejemplo, elija M16F62X.INC si necesita la configuración para un 16F628). Abra
el archivo con algo como el Bloc de notas - (no realice ningún cambio en él) y eche un vistazo a lo
que contiene el archivo ... Revela la vida sexual interna del PIC. Todos los Definiciones de fusibles
de configuración que puede usar desde PBP se enumeran aquí en la parte superior, y más abajo se
enumeran todos los registros. Si no está en la lista, no puedes usarlo, pero confía en mí, por lo
general está todo ahí. Recuerde, esta lista es para usar con el PM (ensamblador predeterminado).

3.b. Cuando se utiliza el ensamblador de Microchip (MPASM)

Si va a usar MPASM, busque el archivo apropiado (por ejemplo, un 16F628 busque P16F628.INC)
ubicado en algo así como el subdirectorio MCHIP_Tools de su instalación MPLAB. Aquí encontrará
los bits de configuración ubicados cerca del final de la lista.

You might also like