;
; uchar duty = 0; // duty cycle counter, 0..255
; uchar Led0,Led1,Led2 = 0; // R/G/B Led duty cycle, 0..255
; uchar shadow = 0; // gpio shadow register
;
; void interrupt() // 40 usec timer 2 interrupts
; { pir1.TMR2IF = 0; // clear timer 2 interrupt flag
; if(Led0 = duty) //
; shadow.0 = 0; // turn off Led0 bit in shadow
; if(Led1 = duty) //
; shadow.1 = 0; // turn off Led1 bit in shadow
; if(Led2 = duty) //
; shadow.2 = 0; // turn off Led2 bit in shadow
; gpio = shadow; // update gpio from shadow
; duty++; // bump duty cycle counter
; if(duty == 0) // if end of period
; shadow = 0b00000111; // reset shadow
; }
;
movf duty,W ; 0..255
xorwf Led0,W ; same as Led0 duty cycle?
skpnz ; no, skip, else
bcf shadow,0 ; turn off Led0 bit in shadow
movf duty,W ; 0..255
xorwf Led1,W ; same as Led1 duty cycle?
skpnz ; no, skip, else
bcf shadow,1 ; turn off Led1 bit in shadow
movf duty,W ; 0..255
xorwf Led2,W ; same as Led2 duty cycle?
skpnz ; no, skip, else
bcf shadow,2 ; turn off Led2 bit in shadow
movf shadow,W ;
movwf PORTB ; update port from shadow
movlw b'00000111' ;
incf duty,F ; end of period?
skpnz ; no, branch, else
movwf shadow ; reset shadow
isr.exit