Hi,
You are overwriting the two LSB's of the dutycycle because you have CCP1CON = %00001100 within the FOR/NEXT loop. So you're actually only updating the dutycycle once every four times thru the loop.
Move the initialisation of the CCP module outside of the FOR/NEXT loop.
Code:
DUTY VAR word
TRISC.2 = 0
PR2 = 200 ' Set PWM Period
CCP1CON = %00001100 ' Select PWM Mode
T2CON = %00000101 ' Timer2 = ON + 1:4 prescale ( about 10 KHz )
Main:
FOR DUTY=260 TO 325
ccp1con.bit4=duty.bit0
ccp1con.bit5=duty.bit1
CCPR1L = duty>>2
debug dec duty, 13 ,10
pause 1000 ' change duty every one sec.
next duty
goto main
/Henrik.
Bookmarks