;PART OF CODE:
Main:
movlw .7 ;serial data has to be shifted seven times
movwf shift_count
movfw units ;zero at start-up, incremented later by button
call Binaryto7seg ;get led segment data corresponding to value of 'units'
movwf LED1
Shift_bits:
rrf LED1
;determine state of data bit
btfsc STATUS,C ;is the data bit '1'?
bsf PORTC,0 ;yes, copy the data bit to the port bit
;data clk
bsf PORTC,1 ;clk pulse low to high shifts data bit into Q0 74HC164
bcf PORTC,1 ;clk pulse low
bcf PORTC,0 ;set it to '0' if it had been set to '1'
decfsz shift_count
goto Shift_bits
;turn the digits on/off
call Display
;test the switch input
btfsc PORTA,0 ;is RA0 low (switch pressed)?
goto Main ;no
;count up
incf units ;yes
movlw .10
subwf units,w
btfsc STATUS,Z
clrf units
;test the switch input
btfsc PORTA,0 ;is RA0 high (switch released)?
goto Main ;yes
call Display ;no
goto $-3 ;loop until switch released
goto Main ;no
;__________________________________________________________________________________________________________
Display:
;Digit_on_time:
bsf PORTC,7 ;Drive the mosfet to show the digit
clrf TMR2
btfss T2_done
goto $-1
bcf T2_done
;Digit_off_time:
bcf PORTC,7
clrf TMR2
btfss T2_done
goto $-1
bcf T2_done
return