Finns det någon möjlighet för er att förstå varför baserat på denna info?
Ser liksom inte logiken i varför det skulle bli skillnad om jag placerar call delay allra först eller näst sist. Sekventiellt så är det ju samma sak bortsett från en goto som inte borde inverka ett dugg.
Tack...
Kod: Markera allt
main_loop
call delay
banksel TRISB
movlw 0xF0 ;get column
movwf TRISB ;high 4 bits in, low 4 bits out
banksel PORTB
movwf PORTB ;send out 0xF0 on portb to determine column
movf PORTB,w ;put value on portb in w
movwf keyboard_value ;save it in keyboard_value
movlw 0xF0
subwf keyboard_value,w
btfsc STATUS,Z ;check if keyboard_value is different from idle state
goto main_loop
call delay ;delay to be sure the value read is correct and stable to prevent bounce effect
movf PORTB,w ;read again
movwf keyboard_value
movlw 0xF0
subwf keyboard_value,w
btfsc STATUS,Z
goto main_loop
banksel TRISB
movlw 0x0F ;get row
movwf TRISB ;high 4 bits out, low 4 bits in
banksel PORTB
movf keyboard_value,w
movwf PORTB ;put keyboard_value on portb to determine row
movf PORTB,w
movwf keyboard_value ;save combined row colum in keyboard_value
;special characters for start and stop
VB7 ;#
movlw 0xB7
subwf keyboard_value,w
btfss STATUS,Z ;is keyboard value = b7 = start_clock?
goto VE7 ;no, check if it is = stop_clock
movlw .2 ;yes, now check if a digit for the display has already been entered
subwf main_counter,w
btfss STATUS,Z
goto prep_vb7_goto_invalid ;if so, then start_clock should not be entered as value for second digit, therefore error
call start_clock ;if not, then it is ok to call start_clock
incf main_counter,f ;since value for display has not been entered increment it because in main_loop_prep_end it will be decremented and it will remain
goto main_loop_prep_end
prep_vb7_goto_invalid ;this increments main_counter so that in the invalid state when main_counter is 1 it is not decremented to 1 again before next loop
incf main_counter,f
goto invalid
;allowed digits
VE7 ;*
movlw 0xE7
subwf keyboard_value,w
btfss STATUS,Z
goto VEE
movlw .2
subwf main_counter,w
btfss STATUS,Z
goto prep_ve7_goto_invalid
bsf PORTA,3 ;kill noise
call stop_clock
incf main_counter,f
goto main_loop_prep_end
prep_ve7_goto_invalid
incf main_counter,f
goto invalid
VEE ;1
DECODE_DIGIT_JUMP 0xEE, VDE, 0x01, load_one_vee, load_ten_vee, main_loop_prep_end
VDE ;2
DECODE_DIGIT_JUMP 0xDE, VBE, 0x02, load_one_vde, load_ten_vde, main_loop_prep_end
VBE ;3
DECODE_DIGIT_JUMP 0xBE, VED, 0x03, load_one_vbe, load_ten_vbe, main_loop_prep_end
VED ;4
DECODE_DIGIT_JUMP 0xED, VDD, 0x04, load_one_ved, load_ten_ved, main_loop_prep_end
VDD ;5
DECODE_DIGIT_JUMP 0xDD, VBD, 0x05, load_one_vdd, load_ten_vdd, main_loop_prep_end
VBD ;6
DECODE_DIGIT_JUMP 0xBD, VEB, 0x06, load_one_vbd, load_ten_vbd, main_loop_prep_end
VEB ;7
DECODE_DIGIT_JUMP 0xEB, VDB, 0x07, load_one_veb, load_ten_veb, main_loop_prep_end
VDB ;8
DECODE_DIGIT_JUMP 0xDB, VBB, 0x08, load_one_vdb, load_ten_vdb, main_loop_prep_end
VBB ;9
DECODE_DIGIT_JUMP 0xBB, VD7, 0x09, load_one_vbb, load_ten_vbb, main_loop_prep_end
VD7 ;0
DECODE_DIGIT_JUMP 0xD7, invalid, 0x00, load_one_vd7, load_ten_vd7, main_loop_prep_end
invalid ;end up here if invalid number value or start and stop buttons are pressed as second digit
incf main_counter,f
clrf one_minutes
clrf ten_minutes
main_loop_prep_end
call serial_output
decfsz main_counter,f
goto main_loop_end
bsf clock_set,0
movlw .2
movwf main_counter
main_loop_end
key_release_loop ;waits on till keyboard key pressed is released
movlw 0x0F
movwf PORTB
subwf PORTB,W
btfss STATUS,Z
goto key_release_loop
goto main_loop
