æ±ç¼å¸®ä½ åä¸ä¸ª Sec EQU 78H
MM EQU 7BH
TM BIT 00H
STOP BIT 9H
KEY_1_DL BIT 2H
KEY_2_DL BIT 3H
KEY_3_DL BIT 4H
KEY_1_ZX BIT 5H
KEY_2_ZX BIT 6H
KEY_3_ZX BIT 7H
FLG BIT 8H
KEY_4_ZX BIT 10H
KEY_4_DL BIT 11H ORG 0000H
LJMP INIT
ORG 000BH
LJMP INIT0
INIT: MOV SP,#60H ;主ç¨åºåå§å
MOV TMOD,#01H ;éæ©å®æ¶å¨/计æ°å¨T0çæ¹å¼1
MOV TL0,#0B0H ;对ä½ä½èµåå¼
MOV TH0,#03CH ;é«ä½èµåå¼
SETB EA
SETB ET0
SETB TR0
SETB STOP
START1: LCALL ST LCALL KEYSCAN
SJMP START1 ST: JB STOP,TZ
SETB P3.1
CLR P3.0
SJMP OU
TZ: CLR P3.1
SETB P3.0
MOV SEC,#00H
OU: RET
INIT0: PUSH ACC
PUSH PSW
CLR ET0
CLR TR0
MOV TL0,#0B0H
MOV TH0,#03CH
SETB TR0
INC MM
MOV B,#02H
MOV A,MM
DIV AB
MOV A,B
CJNE A,#00H,OUTN
SETB TM
OUTN: MOV A,MM
CJNE A,#14H,OUTT0 ;50msæ¯å¦å°20次ï¼æ²¡æå°å°±ç»§ç»æ§è¡50msç延æ¶
MOV MM,#00
JB FLG,OUTT0 ; PAUSE FLAG
INC SEC
MOV A,sec
CJNE A,#3CH,OUTT0 ;ä¸ç§ç延æ¶æ¯å¦è®¡å°60次ï¼æ²¡æ就继ç»æ§è¡
MOV sec,#00
SETB STOP
CLR FLG
OUTT0:SETB ET0 ;å¯å¨å®æ¶å¨T0
POP PSW
POP ACC
RETI KEYSCAN: JB TM, KEYS
SJMP KEYOUT
KEYS: CLR TM
JNB P3.2,KEYSCAN0
JNB KEY_1_ZX,KEY2S
CLR KEY_1_ZX ;P1.0ææé®æä¸å跳转å°åç¨åº
KEY2S: JNB P1.0,KEYSCAN1
JNB KEY_2_ZX,KEY3S
CLR KEY_2_ZX ;P1.1ææé®æä¸å跳转å°åç¨åº
KEY3S: JNB P1.1,KEYSCAN2
JNB KEY_3_ZX,KEY4S
CLR KEY_3_ZX
KEY4S: JNB P1.2,KEYSCAN4
JNB KEY_4_ZX,KEYOUT
CLR KEY_4_ZX
KEYOUT: RET KEYSCAN0: JB KEY_1_ZX,KEYOUT
JB KEY_1_DL,WAITO
SETB KEY_1_DL
SJMP KEYOUT WAITO: SETB KEY_1_ZX
SETB FLG ; 设置æåæ å¿
SETB STOP
SJMP KEYOUT KEYSCAN1: JB KEY_2_ZX,KEYOUT
JB KEY_2_DL,WAIT1
SETB KEY_2_DL
SJMP KEYOUT
WAIT1: SETB KEY_2_ZX SJMP KK
KEYSCAN4: JB KEY_4_ZX,KEYOUT
JB KEY_4_DL,WAIT1
SETB KEY_4_DL
SJMP KEYOUT
WAIT4: SETB KEY_4_ZX SJMP KK KEYSCAN2: JB KEY_3_ZX,KEYOUT
JB KEY_3_DL,WAIT2
SETB KEY_3_DL ;20msç延æ¶æ¶æ
SJMP KEYOUT
WAIT2: SETB KEY_3_ZX ;å¤ææ¯å¦æ¾å¼æé®
KK: JB FLG ,HUI
MOV SEC,#00H
CLR STOP
SJMP KEYOUT HUI: CLR FLG
CLR STOP SJMP KEYOUT
END
温馨提示:内容为网友见解,仅供参考