0% found this document useful (0 votes)
16 views2 pages

PIC Assembly __CONFIG Directive Explained

Uploaded by

ticebekhulu.nt
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

PIC Assembly __CONFIG Directive Explained

Uploaded by

ticebekhulu.nt
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd

The __CONFIG directive in PIC assembly language is used to set configuration bits that control

various operational settings of the microcontroller. These settings are crucial for defining how
the microcontroller behaves in different modes. The two __CONFIG statements you provided
configure the microcontroller in different ways. Here's a detailed comparison:

Configuration using Named Constants


assembly
Copy code
__CONFIG _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF &
_BODEN_ON & _LVP_OFF & _CPD_OFF & _WRT_OFF & _DEBUG_OFF & _CP_OFF
This __CONFIG statement uses named constants for clarity and readability. Each named constant
represents a specific configuration bit setting. Here's what each of these settings means:

 _INTRC_OSC_NOCLKOUT: Uses the internal RC oscillator with no clock output on the RA6
pin.
 _WDT_OFF: Disables the Watchdog Timer.
 _PWRTE_ON: Enables the Power-up Timer (to allow the power supply to stabilize).
 _MCLRE_OFF: Disables the Master Clear (MCLR) pin function, using it as a general I/O
pin instead.
 _BODEN_ON: Enables Brown-out Detection to monitor the power supply voltage.
 _LVP_OFF: Disables Low-Voltage Programming mode.
 _CPD_OFF: Disables Data Memory Code Protection.
 _WRT_OFF: Disables Flash Memory Write Protection.
 _DEBUG_OFF: Disables the Debug mode.
 _CP_OFF: Disables Flash Memory Code Protection.

Configuration using Hexadecimal Literal


assembly
Copy code
__CONFIG H'3FF1'
This __CONFIG statement uses a hexadecimal literal to set the configuration bits. The value
H'3FF1' represents a binary configuration value for the configuration registers.

To understand what this hexadecimal value represents, you need to convert it to binary and map
it to the configuration bits. For the PIC16F818, this hexadecimal value translates to:

 3FF1 in binary: 0011 1111 1111 0001

Mapping this to the configuration bits:

 Bits 15-13 (Configuration Word 1, Oscillator Selection):


o 001 => INTRC_OSC_NOCLKOUT (Internal RC oscillator, no clock output on RA6)
 Bits 12 (Watchdog Timer Enable):
o 1 => WDT_OFF (Watchdog Timer disabled)
 Bits 11 (Power-up Timer Enable):
o 1 => PWRTE_ON (Power-up Timer enabled)
 Bits 10 (MCLR Pin Function):
o 0 => MCLRE_OFF (MCLR pin function disabled)
 Bits 9 (Brown-out Detection Enable):
o 1 => BODEN_ON (Brown-out Detection enabled)
 Bits 8 (Low-Voltage Programming):
o 0 => LVP_OFF (Low-Voltage Programming disabled)
 Bits 7 (Data Memory Code Protection):
o 0 => CPD_OFF (Data Memory Code Protection disabled)
 Bits 6 (Flash Memory Write Protection):
o 0 => WRT_OFF (Flash Memory Write Protection disabled)
 Bits 5 (Debug Mode):
o 0 => DEBUG_OFF (Debug mode disabled)
 Bits 4-0 (Flash Memory Code Protection):
o 11111 => CP_OFF (Flash Memory Code Protection disabled)

Summary
 Named Constants: More readable and understandable, providing a clear description of
each configuration bit setting.
 Hexadecimal Literal: More compact but requires understanding of the bit mappings and
hexadecimal representation to decode the settings.

Both methods ultimately set the same configuration bits, but the named constants approach is
more user-friendly and less error-prone for configuration settings.

You might also like