HPWM is intended for standard CCP PWM modules. It does not work for enhanced PWM
modules. You'll need to set things up manually.
I don't have an 18F4620 to test this with, but see if this doesn't work;
Code:
DEFINE OSC 20
Duty VAR WORD ' 5%=25, 95%=450
TRISC.2=0
TRISD.5=0
T2CON = %00000101 ' Timer2 ON, prescale 1:4
PR2 = 124 ' 10kHz
CCP1CON = %10001100' half-bridge with P1A & P1B
Loop:
For Duty = 25 TO 450 ' from 5% to 95% duty
CCP1CON.4 = Duty.0 ' Setup 10-bit duty cycle as
CCP1CON.5 = Duty.1 ' a 10-bit word
CCPR1L = Duty >> 2
PAUSE 250
Next
Goto loop
End
Bookmarks