Device = 18F6585
Config_Start
OSC = HS ;HS oscillator
OSCS = OFF ;Oscillator system clock switch option is disabled (main oscillator is source)
PWRT = On ;PWRT enabled
BOR = On ;Brown-out Reset enabled
BORV = 27 ;VBOR set to 2.7V
WDT = OFF ;WDT disabled (control is placed on the SWDTEN bit)
WDTPS = 32768 ;1:32768
CCP2MX = On ;CCP2 input/output is multiplexed with RC1
MCLRE = On ;MCLR pin enabled, RG5 input pin disabled
STVR = On ;Stack full/underflow will cause Reset
LVP = OFF ;Low-voltage ICSP disabled
Debug = OFF ;Background debugger disabled. RB6 and RB7 configured as general purpose I/O pins.
Cp0 = OFF ;Block 0 (000800-003FFFh) not code-protected
CP1 = OFF ;Block 1 (004000-007FFFh) not code-protected
CP2 = OFF ;Block 2 (008000-00BFFFh) not code-protected
CPB = OFF ;Boot block (000000-0007FFh) not code-protected
CPD = OFF ;Data EEPROM not code-protected
WRT0 = OFF ;Block 0 (000800-003FFFh) not write-protected
WRT1 = OFF ;Block 1 (004000-007FFFh) not write-protected
WRT2 = OFF ;Block 2 (008000-00BFFFh) not write-protected
WRTC = OFF ;Configuration registers (300000-3000FFh) not write-protected
WRTB = OFF ;Boot block (000000-0007FFh) not write-protected
WRTD = OFF ;Data EEPROM not write-protected
EBTR0 = OFF ;Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
EBTR1 = OFF ;Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
EBTR2 = OFF ;Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
EBTRB = OFF ;Boot block (000000-0007FFh) not protected from table reads executed in other blocks
Config_End
Xtal = 26 'Use 26MHz crystal
'PWM_SETUP
TRISC.2 = 1 'Configure P1A as input
PR2 = 12 'Set PWM period to 2 uS
CCP1CON = %00001100 'Single PWM output P1A - active high
CCPR1L = 6 'Set PWM duty cycle to 50%
PIR1.1 = 0 'Clear Timer2 Interrupt Flag
T2CON = 0 'Timer2 prescaller 1:1
T2CON.2 = 1 'Start Timer2
DelayCS 13 'Wait 13 cycles for Timer2 to overflow
TRISC.2 = 0 'Configure P1A As Output
ECCP1AS = 0 'Clear ECCPASE bit
While 1 = 1 : Wend 'Do something else - empty loop