;
; 8-Digit 9-Pin Charlieplexed CC LED ISR Sample Code
; (14-bit core instructions)
;
; Vars - BITPOS (float bit & digit position)
; BUFPTR (buffer pointer)
; DIGIT1 (start of 8 byte display data buffer)
; (bit 7=dp, bit 6=G...bit 0=A)
;
ISR_LED bsf STATUS,RP0 ;Bank 1 (RP1 is clr) |B1
movlw b'11111111' ; |B1
movwf TRISB ;turn off display |B1
bcf STATUS,RP0 ;Bank 0 (RP1 is clr) |B0
xorwf BITPOS,W ;inv float/column bits |B0
movwf PORTB ;new output pattern |B0
;
bcf PORTA,0 ;turn 'float bit' off |B0
movf BUFPTR,W ;ptr to current digit |B0
movwf FSR ;setup indirect address |B0
movf INDF,W ;get digit segment data |B0
andwf BITPOS,W ;AND float/column bit |B0
btfss STATUS,Z ;need the float bit? |B0
bsf PORTA,0 ;yes, 'float' bit on |B0
iorwf BITPOS,W ;pickup the BITPOS bit |B0
iorwf INDF,W ;get digit segment bits |B0
xorlw b'11111111' ;invert all bits |B0
bsf STATUS,RP0 ;Bank 1 (RP1 is clr) |B1
movwf TRISB ;display new digit |B1
bcf STATUS,RP0 ;Bank 0 (RP1 is clr) |B0
;
incf BUFPTR,f ;increment buffer ptr |B0
bcf STATUS,C ;clear carry bit |B0
rlf BITPOS,f ;shift our digit bit |B0
btfss STATUS,C ;all 8 digits scanned? |B0
goto ISR_NXT ;no, branch |B0
;
rlf BITPOS,f ;reset to b'00000001' |B0
movlw DIGIT1 ;get buffer address |B0
movwf BUFPTR ;reset the pointer |B0
;
ISR_NXT