Κώδικας:
include <p16f887.inc>
temp equ h'20'
temp1 equ h'21'
temp2 equ h'22'
temp3 equ h'23'
temp_s equ h'35'
W_TEMP equ h'36'
STATUS_TEMP equ h'37'
PCLATH_TEMP equ h'38'
W_TEMP1 equ h'A0'
W_TEMP2 equ h'120'
W_TEMP3 equ h'1A0'
org h'0000'
nop
goto START
org h'0004'
;Kwdikas kathusterisis.
movlw d'84'
movwf temp2
movlw d'39'
movwf temp3
LABEL_38
movlw d'11'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_38
decfsz temp3,f
goto LABEL_38
nop
movwf W_TEMP
swapf STATUS,w
clrf STATUS
movwf STATUS_TEMP
movf PCLATH,w
movwf PCLATH_TEMP
;arxi_ISR
incf temp_s,f
;telos_ISR
CONTINUE_ISR
bcf INTCON,INTF
movf PCLATH_TEMP,w
movwf PCLATH
swapf STATUS_TEMP,w
movwf STATUS
swapf W_TEMP,f
swapf W_TEMP,w
retfie
; Interrupt Service Routine till here
START
clrf temp
bcf ANSELH,4
bcf STATUS,RP1
bsf TRISB,0
bcf OPTION_REG,INTEDG
bcf STATUS,RP0
bsf INTCON,INTE
bcf INTCON,INTF
bsf INTCON,GIE
clrf temp_s
movlw d'79'
movwf temp_s
;Arxikopoihsh_Eisodwn_RD
bsf STATUS,RP0
bcf TRISD,0
bcf STATUS,RP0
bcf PORTD,0 ;stelnei 0
bsf STATUS,RP0
bcf TRISD,1
bcf STATUS,RP0
bcf PORTD,1 ;stelnei 0
bsf STATUS,RP0
bcf TRISD,2
bcf STATUS,RP0
bcf PORTD,2 ;stelnei 0
bsf STATUS,RP0
bcf TRISD,3
bcf STATUS,RP0
bcf PORTD,3 ;stelnei 0
bsf STATUS,RP0
bcf TRISD,4
bcf STATUS,RP0
bcf PORTD,4 ;stelnei 0
bsf STATUS,RP0
bcf TRISD,5
bcf STATUS,RP0
bcf PORTD,5 ;stelnei 0
bsf STATUS,RP0
bcf TRISD,6
bcf STATUS,RP0
bcf PORTD,6 ;stelnei 0
bsf STATUS,RP0
bcf TRISD,7
bcf STATUS,RP0
bcf PORTD,7 ;stelnei 0
;Arxikopoihsh_Eisodwn_RC
bsf STATUS,RP0
bcf TRISC,0
bcf STATUS,RP0
bcf PORTC,0 ;stelnei 0
bsf STATUS,RP0
bcf TRISC,1
bcf STATUS,RP0
bcf PORTC,1 ;stelnei 0
;*************Kathusterisi_gia_anama_othonis************
;Kwdikas kathusterisis.(17.5ms)
movlw d'84'
movwf temp2
movlw d'35'
movwf temp3
LABEL_1
movlw d'2'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_1
decfsz temp3,f
goto LABEL_1
;********************Arxikopoihsh*************************
bcf PORTD,0
bcf PORTD,1
bsf PORTD,2
bsf PORTD,3
bsf PORTD,4
bsf PORTD,5
bcf PORTD,6
bcf PORTD,7
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_5
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_5
decfsz temp3,f
goto LABEL_5
bsf PORTC,1
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_6
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_6
decfsz temp3,f
goto LABEL_6
bcf PORTC,1
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_7
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_7
decfsz temp3,f
goto LABEL_7
;********************Cursor/Home*************************
bsf PORTD,0
bcf PORTD,1
bsf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bcf PORTD,6
bcf PORTD,7
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_8
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_8
decfsz temp3,f
goto LABEL_8
bsf PORTC,1
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_9
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_9
decfsz temp3,f
goto LABEL_9
bcf PORTC,1
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_10
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_10
decfsz temp3,f
goto LABEL_10
bsf PORTC,0 ;******SR=1****Eisagwgi_dedomenwn***
LABEL_MAIN_PROGRAM
call LABEL_Button
;********************Keno**********************
bcf PORTD,0
bcf PORTD,1
bcf PORTD,2
bcf PORTD,3
bcf PORTD,4
bsf PORTD,5
bcf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************A**********************
bsf PORTD,0
bcf PORTD,1
bcf PORTD,2
bcf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************B**********************
bcf PORTD,0
bsf PORTD,1
bcf PORTD,2
bcf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************C**********************
bsf PORTD,0
bsf PORTD,1
bcf PORTD,2
bcf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************D**********************
bcf PORTD,0
bcf PORTD,1
bsf PORTD,2
bcf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************E**********************
bsf PORTD,0
bcf PORTD,1
bsf PORTD,2
bcf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************F**********************
bcf PORTD,0
bsf PORTD,1
bsf PORTD,2
bcf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************G**********************
bsf PORTD,0
bsf PORTD,1
bsf PORTD,2
bcf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************H**********************
bcf PORTD,0
bcf PORTD,1
bcf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************I**********************
bsf PORTD,0
bcf PORTD,1
bcf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************J**********************
bcf PORTD,0
bsf PORTD,1
bcf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************K**********************
bsf PORTD,0
bsf PORTD,1
bcf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************L**********************
bcf PORTD,0
bcf PORTD,1
bsf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************M**********************
bsf PORTD,0
bcf PORTD,1
bsf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************N**********************
bcf PORTD,0
bsf PORTD,1
bsf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************O**********************
bsf PORTD,0
bsf PORTD,1
bsf PORTD,2
bsf PORTD,3
bcf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************P**********************
bcf PORTD,0
bcf PORTD,1
bcf PORTD,2
bcf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************Q**********************
bsf PORTD,0
bcf PORTD,1
bcf PORTD,2
bcf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************R**********************
bcf PORTD,0
bsf PORTD,1
bcf PORTD,2
bcf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************S**********************
bsf PORTD,0
bsf PORTD,1
bcf PORTD,2
bcf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************T**********************
bcf PORTD,0
bcf PORTD,1
bsf PORTD,2
bcf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************U**********************
bsf PORTD,0
bcf PORTD,1
bsf PORTD,2
bcf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************V**********************
bcf PORTD,0
bsf PORTD,1
bsf PORTD,2
bcf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************W**********************
bsf PORTD,0
bsf PORTD,1
bsf PORTD,2
bcf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************X**********************
bcf PORTD,0
bcf PORTD,1
bcf PORTD,2
bsf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************Y**********************
bsf PORTD,0
bcf PORTD,1
bcf PORTD,2
bsf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
call LABEL_Button
;********************Z**********************
bcf PORTD,0
bsf PORTD,1
bcf PORTD,2
bsf PORTD,3
bsf PORTD,4
bcf PORTD,5
bsf PORTD,6
bcf PORTD,7
nop
call LABEL_kathusterisi
goto LABEL_MAIN_PROGRAM
;***********YPOROUTINES***************************
LABEL_kathusterisi
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_2
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_2
decfsz temp3,f
goto LABEL_2
bsf PORTC,1
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_3
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_3
decfsz temp3,f
goto LABEL_3
bcf PORTC,1
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_4
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_4
decfsz temp3,f
goto LABEL_4
call LABEL_dieuthunsi
btfss PORTC,4
goto $-1
return
LABEL_Button
btfsc PORTC,4
goto $-1
;kathusterisi_mhxanikwn_anapidisewn_~50ms.
movlw d'84'
movwf temp2
movlw d'39'
movwf temp3
LABEL_A
movlw d'33'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_A
decfsz temp3,f
goto LABEL_A
return
LABEL_dieuthunsi
bcf PORTC,0 ;******SR=0
;********************dieuthunsi**********************
bcf PORTD,0
bcf PORTD,1
bcf PORTD,2
bcf PORTD,3
bcf PORTD,4
bcf PORTD,5
bcf PORTD,6
bsf PORTD,7
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_88
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_88
decfsz temp3,f
goto LABEL_88
nop
bsf PORTC,1
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_89
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_89
decfsz temp3,f
goto LABEL_89
nop
bcf PORTC,1
;Kwdikas kathusterisis.(5ms)
movlw d'5'
movwf temp2
movlw d'15'
movwf temp3
LABEL_90
movlw d'1'
movwf temp1
decfsz temp1,f
goto $-1
decfsz temp2,f
goto LABEL_90
decfsz temp3,f
goto LABEL_90
bsf PORTC,0 ;******SR=1
return
goto $
end