按键扫描
;==========================================
KEY_SCAN:
JBS B_TCCINT1
RET
BC B_TCCINT1
;
JBC P_KEY
JMP KEY_RELEASE
;
INC KEY_COUNT1
MOV A,@15
SUB A,KEY_COUNT1
JBS C
RET
CLR KEY_COUNT1 ;30ms
CLR KEY_COUNT2
;
JBC B_ENKEY
RET
BS B_ENKEY
;
INC KEY_MODE
MOV A,@3
SUB A,KEY_MODE
JBC C
CLR KEY_MODE
SCAN_MODE1:
MOV A,KEY_MODE
JBS Z
JMP SCAN_MODE2
BC 0X06.0
BS 0X06.1
RET
SCAN_MODE2:
MOV A,@1
XOR A,KEY_MODE
JBS Z
JMP SCAN_MODE3
BC 0X06.1
;BC 0X06.0
BS 0X06.0
;BS 0X06.1
RET
SCAN_MODE3:
BS 0X06.0
BS 0X06.1
RET
;
KEY_RELEASE:
INC KEY_COUNT2
MOV A,@15
SUB A,KEY_COUNT2
JBS C
RET
CLR KEY_COUNT1
CLR KEY_COUNT2
BC B_ENKEY
RET |