CONFIG PIC18CXXX Example

MPASM Assembler

CONFIG PIC18CXXX Example

Directives highlighted in this example for PIC18CXXX devices are:

  • _ _ config

Program Functional Description

This program demonstrates the utility of the _ _ config directive. This directive is used to program configuration bits in the configuration register during device programming.

Commented Code Listing

list p=18c452 ;Select the device.

#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

RST CODE H'0' ;The code section named RST

;is placed at H'0'.

;The instruction 'goto start'

;is placed in code section RST.

goto start ;Jumps to the location labelled

;'start'.

INTRT CODE H'8' ;The code section named INTRT

;is placed at H'4'.

;The instruction 'goto service_int'

;is placed in code section INTRT.

goto service_int ;Jumps to the location labelled

;'service_int'.

PGM CODE ;This is the begining of the code

;section named PGM. It is a

;relocatable code section

;since no absolute address is

;given along with directive

start ;'CODE'.

goto $

service_int

retfie

end


Microchip Technology Inc.
Microchip's Web Site
Voice: (480) 792-7200
Fax: (480) 899-9210
Microchip's E-mail Address
PreviousNext