SetOut Bank1 ;select data direction register page clrf TRISA ;set all PORTA pins to output ;a voltage on RA0-RA7 Bank0 ;back to user memory page SetOn movlw number ;value 0-15 in W call Bin2LED ;load W with 7-segment pattern movwf PORTA ;output to Digit2 return Bin2LED andlw %00001111 ;restrict index to 0-15, 16 elements brw ;branch into table with W as index retlw %00111111 ;return with pattern for '0' in W retlw %00000110 ;return with pattern for '1' in W ----- --------- ;13 other lines with proper patterns retlw %01110001 ;return with pattern for 'F' in W ******************************************************************************** SetOut Bank1 clrf TRISA ;PORTA tri-state register: 0=out, 1=in bcf TRISC,1 ;set PORTC bit 1 to output voltage on RC1 bcf TRISC,2 ;set PORTC bit 2 to output voltage on RC2 Bank0 DELAY equ 250 ;define a constant to use in the program bcf PORTC,1 ;turn off transistor, disable Digit1 bcf PORTC,2 ;turn off transistor, disable Digit2 Start movlw 1 ;load W with 1 call Bin2LED ;load W with 7 segment bit pattern for '1' movwf PORTA ;display 7-segment '1' bsf PORTC,1 ;turn on transistor, enable Digit1 movlw DELAY ;load W with value in DELAY call Wait ;pause 97us times value in DELAY bcf PORTC,1 ;disable Digit1 movlw 2 ;load W with 2 call Bin2LED ;load W with 7 segment bit pattern for '2' movwf PORTA ;display 7-segment '2' bsf PORTC,2 ;turn on transistor, enable Digit2 movlw DELAY ;load W with value in DELAY call Wait ;pause 97us times value in DELAY bcf PORTC,2 ;disable Digit2 goto Start ;*back to start Bin2LED ;add the Bin2LED subroutine here ******************************************************************************** SetOut Bank1 clrf TRISA ;PORTA tri-state register: 0=out, 1=in bcf TRISC,1 ;set PORTC bit 1 to output voltage on RC1 bcf TRISC,2 ;set PORTC bit 2 to output voltage on RC2 Bank0 DELAY equ 250 ;define a constant to use in the program cblock 0x20 ;*define variables starting at memory 0x20 SecTens ;*seconds tens digit stored in 0x20 SecOnes ;*seconds units digit stored in 0x21 endc ;*ends cblock definition bcf PORTC,1 ;turn off transistor, disable Digit1 bcf PORTC,2 ;turn off transistor, disable Digit2 ReadSec movf Seconds,W ;*get current Seconds value call W2BCD ;*convert Seconds to BCD digits movf WH,W ;*load tens digit in W movwf SecTens ;*save to SecTens movf WL,W ;*load ones digit in W movwf SecOnes ;*save to SecOnes Show1 movf SecTens,W ;*load W with Seconds tens digit call Bin2LED ;convert value to 7-segment pattern movwf PORTA ;output, setup tens pattern bsf PORTC,1 ;turn on transistor, enable Digit1 movlw DELAY ;load W with value in DELAY call Wait ;pause 97us times value in DELAY bcf PORTC,1 ;disable Digit1 Show2 movf SecOnes,W ;*load W with Seconds ones digit call Bin2LED movwf PORTA ;display ones digit... bsf PORTC,2 ;enable Digit2 movlw DELAY call Wait bcf PORTC,2 ;disable Digit2 goto ReadSec ;*back to start Bin2LED ;add the Bin2LED subroutine here