为什么程序实现不了回放功能?我都找资料找了半个月了没头绪。

2019-07-16 07:05发布

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
0100H
MAIN:
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
START
KEY1:
CJNE
R0,#0FEH,KEY2
;K1
键按下

MOV
30H,#0FEH
;
设置音阶1

MOV
31H,#22H


MOV
P0,#06H


MOV
KONG1,#22H


LCALL
WRITE

LJMP
SET_TIMER
KEY2:

CJNE
R0,#0FDH,KEY3
;K2
键按下


MOV
30H,#0FEH
;
设置音阶2

MOV
31H,#56H

MOV
P0,#5BH


MOV
KONG1,#56H


LCALL
WRITE

LJMP
SET_TIMER
KEY3:
CJNE
R0,#0FBH,KEY4
;K3
键按下

MOV
30H,#0FEH
;
设置音阶3

MOV
31H,#85H

MOV
P0,#4FH


MOV
KONG1,#85H


LCALL
WRITE

LJMP
SET_TIMER
KEY4:
CJNE
R0,#0F7H,KEY5
;K4
键按下

MOV
30H,#0FEH
;
设置音阶4

MOV
31H,#9AH

MOV
P0,#66H


MOV
KONG1,#9AH


LCALL
WRITE

LJMP
SET_TIMER
KEY5:
CJNE
R0,#0EFH,KEY6
;K5
键按下

MOV
30H,#0FEH
;
设置音阶5

MOV
31H,#0C1H

MOV
P0,#6DH


MOV
KONG1,#0C1H


LCALL
WRITE


LJMP
SET_TIMER
KEY6:
CJNE
R0,#0DFH,KEY7
;K6
键按下

MOV
30H,#0FEH
;
设置音阶6

MOV
31H,#0E4H

MOV
P0,#7DH


MOV
KONG1,#0E4H


LCALL
WRITE

LJMP
SET_TIMER
KEY7:
CJNE
R0,#0BFH,KEY8
;K7
键按下

MOV
30H,#0FFH
;
设置音阶7

MOV
31H,#03H

MOV
P0,#07H



MOV
KONG1,#03H


LCALL
WRITE

LJMP
SET_TIMER
KEY8:

CJNE R0,#7FH,NOKEY

MOV
P0,#7FH

LJMP
PLAY
NOKEY:
CLR
TR0

;
无键按下

LJMP
START
     SET_TIMER:
SETB
TR0

LJMP
START
PLAY:
MOV
R3,#0
MUSIC:
MOV
A,R3

MOV
DPTR,#50H

MOVC
A,@A+DPTR

INC

R3

MOV
31H,A

SETB
TR0

LCALL
DELAY100MS

LJMP
MUSIC
DELAY100MS:PUSH
PSW

CLR
RS0


SETB
RS1


MOV
R7,#0C7H
LOOP1:MOV
R6,#0FAH
LOOP2:DJNZ
R6,LOOP2

DJNZ
R7,LOOP1


POP
PSW
RETWRITE: MOV
R1,3FH

MOV
@R1,KONG1


INC
3FH


RET
INT_T0:

MOV
TH0,30H

MOV
TL0,31H

CPL
BUZZ

RETI
END
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。