;
; A minimum PWM 'on' time of 2% guarantees a minimum window
; of 20-usecs (100 instruction cycles) at the beginning of
; each interrupt cycle where PWM drives the <OE> input high
; (display off)... This allows us to reuse the RB1 and RB2
; column driver lines temporarily as '5841 <DAT> and <CLK>
; lines to load the '5841 (without messing up the display)
; before RB1 and RB2 resume their column driver duties when
; PWM drives <OE> low (display on)...
;
; The 2% minimum PWM 'on' time limits maximum brightness to
; 98% but the 2% loss of brightness is inperceivable
;
ISR_LED
movf BUFPTR,W ; get LED seg data buffer ptr |B0
movwf FSR ; setup for indirect address |B0
movf INDF,W ; get seg data for this column |B0
movwf WORK ; put it in the WORK variable |B0
movlw d'8' ; |B0
movwf TEMP ; serial bit count |B0
ISR_Load
bcf SERCLK ; preset '5841 CLK line lo (RB1) |B0
bcf SERDAT ; preset '5841 DAT line lo (RB2) |B0
rlf WORK,f ; shift data bit into Carry |B0
skpnc ; a '1' bit? |B0
bsf SERDAT ; yes, set SERDAT line to 1 |B0
bsf SERCLK ; clock data bit into the '5841 |B0
decfsz TEMP,f ; all 8 bits sent/loaded? |B0
goto ISR_Load ; no, branch and do another |B0
;
; now setup Port B column drivers before PWM drives the '5841
; <OE> pin low to turn on the segment driver outputs & display
;
; COLPOS variable cycles through the following fixed values
; one interrupt at a time to 'scan' the display and switches;
;
; 00000001, column 0, inverted 11111110
; 00000010, column 1, inverted 11111101
; 00000100, column 2, inverted 11111011
; 00001000, column 3, inverted 11110111
; 00010000, column 4, inverted 11101111
; 00100000, column 5, inverted 11011111
; 01000000, column 6, inverted 10111111
; 10000000, column 7, inverted 01111111
;
ISR_Column
comf COLPOS,W ; invert bits (only 1 bit low) |B0
movwf PORTB ; setup the column drivers |B0
;
; prep the ISR 'scan' and buffer pointer variables for the next
; column 'scan' interrupt
;
ISR_NextColumn
incf BUFPTR,f ; increment LEDBUF pointer |B0
bcf STATUS,C ; clear Carry |B0
rlf COLPOS,f ; shift column position |B0
skpc ; all 8 columns scanned? |B0
goto ISR_PWM ; no, branch, else |B0
;
; reset ISR scan and buffer pointer variables for column 0
;
movlw LEDBUF ; reset scan sequence |B0
movwf BUFPTR ; reset LEDBUF pointer |B0
rlf COLPOS,f ; reset COLPOS to 00000001 |B0
;