在DVCC-598JH++平台上 单片机 键盘或者开关切换两首音乐
[复制链接]
附录一段可以正常运行的汇编代码:
org 0000h
Sjmp MAIN
org 000bh
mov th0,r1
mov tl0,r0
cpl p1.0
RETI
MAIN:MOV TMOD,#01H
MOV IE,#82H
MOV DPTR,#TAB
LOOP: CLR A
MOVC A,@A+DPTR
MOV R1,A
INC DPTR
CLR A
MOVC A,@A+DPTR
MOV R0,A
ORL A,R1
JZ NEXT0
MOV A,R0
ANL A,R1
CJNE A,#0FFH,NEXT
SJMP MAIN
NEXT : MOV TH0,R1
MOV TL0,R0
SETB TR0
SJMP NEXT1
NEXT0:CLR TR0
NEXT1: CLR A
INC DPTR
MOVC A,@A+DPTR
MOV R2,A
LOOP1: ACALL D200C
DJNZ R2,LOOP1
INC DPTR
AJMP LOOP
D200C:MOV R3,#81H
D200B:MOV A,#0FFH
D200A:DEC A
JNZ D200A
DEC R3
CJNE R3,#00H,D200B
RET
TAB: DB 0FEH,25H,04H,0FEH,25H,02H
DB 0FEH,25H,02H,0FDH,80H,04H
DB 0FEH,84H,02H,0FEH,84H,02H
DB 0FEH,84H,04H,0FEH,25H,04H
DB 0FEH,25H,02H,0FEH,84H,02H
DB 0FEH,0C0H,04H,0FEH,84H,02H
DB 0FEH,98H,02H,0FEH,84H,02H
DB 0FEH,57H,08H,00H,00H,04H
DB 0FFH,0FFH
END
仅作为参考,仅能播放一首,另外还需利用键盘或者开关切换另外一首
问题补充:另一首
TAB2: DB 0FEH,0E3H,01H,0FEH,0E3H,02H,0FEH,0E3H,01H
DB 0FEH,033H,01H,0FEH,0C0H,01H,0FEH,84H,02H
DB 0FEH,84H,02H,0FEH,57H,02H
DB 0FEH,57H,04H
DB 0FEH,57H,01H,0FEH,57H,01H,0FEH,57H,01H,0FEH,57H,01H
DB 0FEH,57H,01H,0FEH,57H,02H,0FEH,84H,01H,0FDH,0C8H,01H
DB 0FEH,57H,04H
DB 00H,00H,04H
DB 0FFH,0FFH
|