raitl
New Member
I have one IR led working nicely on cpp1. Now I want to add another IR led, but want to be able to switch then on and off independently. So I need to use cpp2 aswell.
Is if enough to take this code:
And add these lines where necessary:
Is if enough to take this code:
Code:
SetupPWM:
; initializes PWM to 38KHz for IR LED
BANK1 ; select register bank 1
movlw 0x34 ; used to calculate PWM period
movwf PR2
BANK0 ; register bank 0
bsf CCP1CON, 4 ; CCP1CON<4:5> used to determine
bcf CCP1CON, 5 ; PWM duty cycle
movlw 0x08 ; set duty cycle
movwf CCPR1L
BANK1 ; register bank 1
bcf TRISC, 2 ; port c is an output
BANK0 ; register bank 0
movlw b'00000100' ;
movwf T2CON ; enable PWM on TIMER2
return
And add these lines where necessary:
Code:
...
bsf CCP2CON, 4
bcf CCP2CON, 5
...
movwf CCPR2L
...
bcf TRISC, 1
...