times New Roman">
BUZZ
EQU P3.0
NUM
EQU
37H
KONG1
EQU
38H
KONG2
EQU
39H
ORG
0000H
LJMP
MAIN
ORG
000BH
LJMP
INT_T0
ORG
0100HMAIN:
MOV
R1,#50H
MOV
30H,#00
MOV
31H,#00
MOV
P1,#0FFH
MOV
TMOD,#01H
SETB
ET0
SETB
EA
;开总中断
CLR
TR0
;关闭定时器0 START:
MOV
3FH,#50H
MOV
R0,P1
CJNE
R0,#0FFH,KEY1
;键盘扫描
CLR
TR0
SJMP
STARTKEY1:
CJNE
R0,#0FEH,KEY2
;K1键按下
MOV
30H,#0FEH
;设置音阶1
MOV
31H,#22H
MOV
P0,#06H
MOV
KONG1,#22H
LCALL
WRITE
LJMP
SET_TIMERKEY2:
CJNE
R0,#0FDH,KEY3
;K2键按下
MOV
30H,#0FEH
;设置音阶2
MOV
31H,#56H
MOV
P0,#5BH
MOV
KONG1,#56H
LCALL
WRITE
LJMP
SET_TIMERKEY3:
CJNE
R0,#0FBH,KEY4
;K3键按下
MOV
30H,#0FEH
;设置音阶3
MOV
31H,#85H
MOV
P0,#4FH
MOV
KONG1,#85H
LCALL
WRITE
LJMP
SET_TIMERKEY4:
CJNE
R0,#0F7H,KEY5
;K4键按下
MOV
30H,#0FEH
;设置音阶4
MOV
31H,#9AH
MOV
P0,#66H
MOV
KONG1,#9AH
LCALL
WRITE
LJMP
SET_TIMERKEY5:
CJNE
R0,#0EFH,KEY6
;K5键按下
MOV
30H,#0FEH
;设置音阶5
MOV
31H,#0C1H
MOV
P0,#6DH
MOV
KONG1,#0C1H
LCALL
WRITE
LJMP
SET_TIMERKEY6:
CJNE
R0,#0DFH,KEY7
;K6键按下
MOV
30H,#0FEH
;设置音阶6
MOV
31H,#0E4H
MOV
P0,#7DH
MOV
KONG1,#0E4H
LCALL
WRITE
LJMP
SET_TIMERKEY7:
CJNE
R0,#0BFH,KEY8
;K7键按下
MOV
30H,#0FFH
;设置音阶7
MOV
31H,#03H
MOV
P0,#07H
MOV
KONG1,#03H
LCALL
WRITE
LJMP
SET_TIMERKEY8:
CJNE R0,#7FH,NOKEY
MOV
P0,#7FH
LJMP
PLAYNOKEY:
CLR
TR0
;无键按下
LJMP
START SET_TIMER:
SETB
TR0
LJMP
STARTPLAY:
MOV
R3,#0MUSIC:
MOV
A,R3
MOV
DPTR,#50H
MOVC
A,@A+DPTR
INC
R3
MOV
31H,A
SETB
TR0
LCALL
DELAY100MS
LJMP
MUSICDELAY100MS:PUSH
PSW
CLR
RS0
SETB
RS1
MOV
R7,#0C7HLOOP1:MOV
R6,#0FAHLOOP2:DJNZ
R6,LOOP2
DJNZ
R7,LOOP1
POP
PSWRETWRITE: MOV
R1,3FH
MOV
@R1,KONG1
INC
3FH
RETINT_T0:
MOV
TH0,30H
MOV
TL0,31H
CPL
BUZZ
RETIEND
一周热门 更多>