Copy 102ASP 的教材裡的 config 的設定。使用內部 RC 設為 1MHz 的 Fosc.
LIST P=18F4520 ;directive to define processor
#include <P18F4520.INC> ;processor specific variable definitions
CONFIG OSC = INTIO7 ; Internal oscillator block, CLKO
; function on RA6,port function on RA7
CONFIG FCMEN = OFF,IESO = OFF
CONFIG PWRT = ON, BOREN = OFF, WDT = OFF,MCLRE = ON
CONFIG PBADEN = OFF ; PORTB<4:0> pins are configured as
; digital I/O on Reset
CONFIG CCP2MX = PORTC ; CCP2 input/output is multiplexed with
; RC1
CONFIG STVREN = OFF, LVP = OFF
CONFIG CPB = OFF, CP0 = OFF, CP1=OFF, CP2 = OFF,CP3 = OFF
有關使用 C18 的 Config 設定請參考 c:\mcc18\doc\hlpPIC18ConfigSet.heml 裡的說明,底下是其設定的語法:
;*******************************************************************************
;*3.For MPLAB C18 V2.40 or higher, use #pragma config directive *
;*for example *
//******************************************************************************
#include <p18f452.h>
//*******************************************************************************
//*Configuration settings may be specified with multiple #pragma config directives. *
//*MPLAB C18 verifies that the configuration settings specified are valid for the processor*
//*for which it is compiling *
//*The labels following the directive "pragma config" are defined in the P18F452.h file. *
//*******************************************************************************
#pragma config OSC=HS
#pragma config PWRT=ON
#pragma config BOR=OFF, BORV=42
#pragma config WDT=OFF
#pragma config CCP2MUX=ON
#pragma config STVR=OFF, LVP=OFF, DEBUG=OFF
#pragma config CPD=OFF
void main(void)
{
//your code
}
//********************************************************************************