mini_2440
03-04-2011, 07:03 PM
em có đoạn code xử lý phím bấm sau:
#DEFINE ScrButton PortB,6
#DEFINE ResetButton PortB,7
.....................
OnChange_INT:
movf PORTB,0 ;End mismatch
bcf INTCON,RBIF
btfss INTCON,RBIE
goto Exit_ISR
btfss ScrButton
goto Button
btfss ResetButton
goto Reset
goto Exit_ISR ; Thoat ngat
Reset:
btfss ScrButton_F
goto Exit_ISR
bcf ScrButton_F
bsf ModeSelect,1
; do some other work
goto Exit_ISR
Button:
bsf STATUS,RP0 ;
bcf OPTION_REG,T0CS ;
bsf INTCON,T0IE ;Activate and enable TMR0
bsf ScrButton_F
; do some other works
goto Exit_ISR
nếu xử lý thêm thời gian chờ nhả phím thì ta phải viết thêm như thế nào, mong các anh em nhiệt tình giúp đỡ.
#DEFINE ScrButton PortB,6
#DEFINE ResetButton PortB,7
.....................
OnChange_INT:
movf PORTB,0 ;End mismatch
bcf INTCON,RBIF
btfss INTCON,RBIE
goto Exit_ISR
btfss ScrButton
goto Button
btfss ResetButton
goto Reset
goto Exit_ISR ; Thoat ngat
Reset:
btfss ScrButton_F
goto Exit_ISR
bcf ScrButton_F
bsf ModeSelect,1
; do some other work
goto Exit_ISR
Button:
bsf STATUS,RP0 ;
bcf OPTION_REG,T0CS ;
bsf INTCON,T0IE ;Activate and enable TMR0
bsf ScrButton_F
; do some other works
goto Exit_ISR
nếu xử lý thêm thời gian chờ nhả phím thì ta phải viết thêm như thế nào, mong các anh em nhiệt tình giúp đỡ.