(基于51核的STC12C5A60S2,keil uvision5 mdk 5.25 编译)
KEY1 BIT P3.2
BEEP BIT P1.0
SM_G1 BIT P2.0
SM_G2 BIT P2.1
SM_G3 BIT P2.2
SM_G4 BIT P2.3
;-----------------------------------------------------------------------------------------------------
KEY1_State DATA 69H ; 将地址69H用伪指令命名为KEY1_State
DelayTimes_100MS EQU 6FH ; 将地址6FH用伪指令命名为DelayTimes_100MS
;----------------------------------------------------------------------------------------------------
CLR BEEP
START:
SETB SM_G1
MOV KEY1_State,#0
LOOP:
JB KEY1,KEY_OFF
MOV DelayTimes_100MS,#2
LCALL Delay100MS
KEY_ON:
CLR SM_G1
LOOP2:
MOV A,KEY1_State
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
MOV DelayTimes_100MS,#5
LCALL Delay100MS
INC KEY1_State
MOV A,KEY1_State
CJNE A,#10,CONTINUE
AJMP START
CONTINUE:
AJMP LOOP2
KEY_OFF:
AJMP LOOP
;--------------------------------------------------------------------------------------------------------
TAB:
DB 0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x19,0x03;
Delay100MS:
MOV R7,DelayTimes_100MS
Delay100MS_1:
MOV R6,#10
Delay100MS_2:
MOV R5,#150
Delay100MS_3:
MOV R4,#200
Delay100MS_4:
DJNZ R4, Delay100MS_4
DJNZ R5, Delay100MS_3
DJNZ R6, Delay100MS_2
DJNZ R7, Delay100MS_1
RET ;子程序返回
END
(基于51核的STC12C5A60S2,keil uvision5 mdk 5.25 编译)
KEY1 BIT P3.2
BEEP BIT P1.0
SM_G1 BIT P2.0
SM_G2 BIT P2.1
SM_G3 BIT P2.2
SM_G4 BIT P2.3
;-----------------------------------------------------------------------------------------------------
KEY1_State DATA 69H ; 将地址69H用伪指令命名为KEY1_State
DelayTimes_100MS EQU 6FH ; 将地址6FH用伪指令命名为DelayTimes_100MS
;----------------------------------------------------------------------------------------------------
CLR BEEP
START:
SETB SM_G1
MOV KEY1_State,#0
LOOP:
JB KEY1,KEY_OFF
MOV DelayTimes_100MS,#2
LCALL Delay100MS
KEY_ON:
CLR SM_G1
LOOP2:
MOV A,KEY1_State
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
MOV DelayTimes_100MS,#5
LCALL Delay100MS
INC KEY1_State
MOV A,KEY1_State
CJNE A,#10,CONTINUE
AJMP START
CONTINUE:
AJMP LOOP2
KEY_OFF:
AJMP LOOP
;--------------------------------------------------------------------------------------------------------
TAB:
DB 0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x19,0x03;
Delay100MS:
MOV R7,DelayTimes_100MS
Delay100MS_1:
MOV R6,#10
Delay100MS_2:
MOV R5,#150
Delay100MS_3:
MOV R4,#200
Delay100MS_4:
DJNZ R4, Delay100MS_4
DJNZ R5, Delay100MS_3
DJNZ R6, Delay100MS_2
DJNZ R7, Delay100MS_1
RET ;子程序返回
END
举报