thanx skimax!
with further investigation i have made a hardware pwm that sets in the background!
here is the code if anyone needs it
INCLUDE "MODEDEFS.BAS"
' ** Declare Variables **
Pause 500
start:
IF PORTB.7=1 Then
TRISC.2 = 0 ' Enable PORTC.2 (CCP1) as output for PWM
T2CON = %00000100 ' Set the Prescaler for 1:1, and turn on TMR2
PR2 = 255 ' See above calculation for the output period
CCPR1L = 128 ' MSB of the 10-bit duty value
CCP1CON.2 = 1 ' Turn on PWM Module one,
CCP1CON.3 = 1 ' by setting bits 2 and 3 of CCP1CON
EndIF
IF PORTB.7=0 Then
CCPR1L = 0
CCP1CON.2 = 1 ' Turn on PWM Module one,
CCP1CON.3 = 1 ' by setting bits 2 and 3 of CCP1CON
High PORTB.6
EndIF
GoTo start
End
Bookmarks