主页 > 焦点科技 >香奈儿粉饼_单片机设计音乐播放器程序和仿真图(用汇编语言)?急求~谢谢!!! >

香奈儿粉饼_单片机设计音乐播放器程序和仿真图(用汇编语言)?急求~谢谢!!!

单片机设计音乐播放器程序和仿真图(用汇编语言)?急求~谢谢!!!

NUMEQU30H
UPEQUP3.6
DNEQUP3.7
ORG0000H
AJMPSTART;Fosc=12MHz
ORG000BH;T0入口地址
AJMPINT_T0
ORG001BH;T1中断入口地址
AJMPINT_T1

START:
MOVSP,#60H
MOVTMOD,#11H
MOVIE,#8AH
MOVIP,#08H ;T1中断优先于T0中断
MOV TH1,#3CH
MOV TL1,#0BH;以上为系统初始化,T=60ms

W1: MOV P2,#01110001B;等待提示"F" ,01110001
LCALL GETKEY
CJNEA,#0FFH,W1
MOVA,B
CJNEA,#0AH,W2
LCALLKEY_A;键是'A',转KEY_A
SJMP W1

W2: CJNE A,#0BH,W3
LCALLKEY_B;输入键是'B',转KEY_B

W3: CJNE A,#0CH,W4
LCALLKEY_C;输入键是'C',转KEY_C
W4: CJNE A,#0DH,W5
LCALLKEY_D
SJMP W1;输入键是'D',转KEY_D
W5: CJNEA,#0EH,W6 ;下一首
INCNUM
MOVA,NUM
CJNEA,#4,W51
W51:
JCW52
MOVNUM,#0
W52:
MOVA,NUM
SJMPD0
W6: CJNEA,#0FH,W7 ;上一首
MOVA,NUM
JNZW61
MOVNUM,#4
W61:
DECNUM
MOVA,NUM
SJMPD0
W7:
SJMP W1
KEY_A:;从1~4按顺序播放
LCALL MUSIC1;乐曲《我和你》
LCALL MUSIC2;乐曲《万水千山总是情》
LCALL MUSIC3;乐曲《送别》
LCALL MUSIC4;乐曲《北京欢迎您》
RET
KEY_B:;从1~4循环播放
T11: LCALL KEY_A
SJMP T11
RET
KEY_C:;循环播放某一乐曲
T3: LCALL GETWORD
CJNE A,#0FFH,T3
MOV A,B
D0:
JNZD1
SJMP E0
D1: DECA
JNZD2
SJMP E1
D2: DECA
JNZE3
SJMP E2
E0: LCALL MUSIC1;乐曲《我和你》
SJMP E0
E1: LCALL MUSIC2;乐曲《万水千山总是情》
SJMP E1
E2: LCALL MUSIC3;乐曲《送别》
SJMP E2
E3: LCALL MUSIC4;乐曲《北京欢迎您》
SJMP E3
RET
KEY_D:;从某一乐曲开始播放,播放完后停止
T2: LCALL GETWORD
CJNE A,#0FFH,T2
MOV A,B
CJNE A,#00H,B1
SJMP C0
B1: CJNE A,#01H,B2
SJMP C1
B2: CJNE A,#02H,C3
SJMP C2
C0: LCALL MUSIC1;乐曲《我和你》
C1: LCALL MUSIC2;乐曲《万水千山总是情》
C2: LCALL MUSIC3;乐曲《送别》
C3: LCALL MUSIC4;乐曲《北京欢迎您》
RET
MUSIC1:;第一首《我和你》
MOVP2,#00000110B;显示1,00000110
MOVR5,#11111001B
MOV52H,#HIGHTABLE10
MOV53H,#LOWTABLE10
MOVNUM,#0
LCALLmusic
RET
MUSIC2:;第二首《万水千山总是情》
MOV P2,#01011011B ;显示2,01011011
MOV R5,#10100100B
MOV52H,#HIGHTABLE20
MOV53H,#LOWTABLE20
MOVNUM,#1
LCALL music
RET
MUSIC3:;第三首《送别》
MOV P2,#01001111B;显示3,01001111
MOV R5,#10110000B
MOV52H,#HIGHTABLE30
MOV53H,#LOWTABLE30
MOVNUM,#2
LCALL music
RET
MUSIC4: ;第四首《北京欢迎您》
MOV P2,#01100110B;显示4,01100110
MOV R5,#10011001B
MOV52H,#HIGHTABLE40
MOV53H,#LOWTABLE40
MOVNUM,#3
LCALL music
RET
music: MOVR3,#00H;音乐解码器
NEXT20:
MOVA,P3
ORLA,#0C0H
MOVP3,A
MOVA,P3
CPLA
ANLA,#0C0H
JZNEXT21
POPACC
POPACC
LJMPW1
RET
NEXT21:
MOVA,R3
MOV DPH,52H
MOV DPL,53H
MOVC A,@A+DPTR
MOV R2,A
JZ STOP
ANL A,#0FH
MOV R1,A
MOV A,R2
SWAP A
ANL A,#0FH
JNZ SING
CLR TR0
JMP W11
;----------------------------------------------------------
SING:
DEC A
MOV22H,A
RL A
MOVDPTR,#TABLE00
MOVC A,@A+DPTR
MOV TH0,A
MOV 21H,A
MOV A,22H
RL A
INC A
MOVC A,@A+DPTR
MOV TL0,A
MOV 20H,A
SETB TR0
SETB TR1
W11:
LCALL DELAY3
INC R3
LJMP NEXT20
;-----------------------------------------------------------
STOP:
CLR TR0
CLR TR1
RET
;***************************************************
;定时器0中断子程序
;***************************************************
INT_T0:
CLR TR0
MOV TL0,20H
MOV TH0,21H
CPL P3.0
SETB TR0
RETI
;***************************************************
;定时器1中断子程序
;***************************************************
INT_T1:
CLRTR1
CLRTR0
LCALL KEY_E
MOVTH1,#3CH
MOVTL1,#0BH
DJNZ 60H,OUT
MOV 60H,#20
OUT:
SETB TR1
RETI
KEY_E:
JB P3.1,L2;中断键盘检测
LCALL DELAY2;消除抖动
JB P3.1,L2;如果是高电平就跳到L2
JNBP3.1,$;如果仍然是低电平就执行中断程序
MOV P2,#0111100B ;让LED显示E,01111001
L3: JB P3.1,$;检测低电平,直到低电平时才跳出该指令
LCALL DELAY2
JB P3.1,L3
JNBP3.1,$;如果再来一个高电平才跳出中断
MOV P2,R5
L2: SETBTR0
RET
GETKEY:;读ABCD键盘子程序
SA: JB P1.0,SB;读A,是高电平表示没有按键,跳转到SB
LCALL DELAY2
JB P1.0,SA
JNB P1.0,$
MOV P2,#01110111B;显示A,01110111
MOV R5,#10001000B
MOV A,#0FFH
MOV B,#0AH
RET
SB: JB P1.1,C11 ;读B,是高电平表示没有按键按下,跳转到C11
LCALL DELAY2
JB P1.1,SB
JNB P1.1,$
MOV P2,#01111100B ;显示B,01111100
MOV R5,#10000011B
MOV A,#0FFH
MOV B,#0BH
RET
C11:JB P1.2,ED1;读C
LCALL DELAY2
JB P1.2,C11
JNBP1.2,$
MOV P2,#00111001B;显示C,00111001
MOV R5,#11000110B
MOV A,#0FFH
MOV B,#0CH
RET
ED1:
JB P1.3,L0;读D
LCALL DELAY2
JB P1.3,ED1
JNBP1.3,$
MOV P2,#01011110B;显示D,01011110
MOV R5,#10100001B
MOV A,#0FFH
MOV B,#0DH
L0: JBUP,L01
LCALLDELAY2
JBUP,L01
JNBUP,$
MOVA,#0FFH
MOVB,#0EH
RET
L01:
JBDN,L02
LCALLDELAY2
JBDN,L02
JNBDN,$
MOVA,#0FFH
MOVB,#0FH
L02:
RET
GETWORD:;读音乐序号子程序
S1: JB P1.4,S2;读1键
LCALL DELAY2
JB P1.4,S1
JNB P1.4,$
MOV P2,#00000110B;显示1
MOV R5,#11111001B
MOV A,#0FFH
MOV B,#00H
RET
S2: JB P1.5,S3;读2键
LCALL DELAY2
JB P1.5,S2
JNB P1.5,$
MOV P2,#01011011B;显示2
MOV R5,#10100100B
MOV A,#0FFH
MOV B,#01H
RET
S3: JB P1.6,S4;读3键
LCALL DELAY2
JB P1.6,S3
JNB P1.6,$
MOV P2,#01001111B;显示3
MOV R5,#10110000B
MOV A,#0FFH
MOV B,#02H
RET
S4: JB P1.7,L1;读4键
LCALL DELAY2
JB P1.7,S1
JNB P1.7,$
MOV P2,#01100110B;显示4
MOV R5,#10011001B
MOV A,#0FFH
MOV B,#03H
L1: RET
DELAY:;延时子程序
PUSH0;保存现场
PUSH1
MOV0,#0H
DELAY1:MOV1,#0H
DJNZ1,$
DJNZ0,DELAY1
POP1;恢复现场
POP0
RET
DELAY2: MOV 41H,#100 ;延时子程序2
F1: MOV 42H,#250
DJNZ 42H,$
DJNZ 41H,F1
RET
DELAY3:;延时子程序3
MOV R7,#2
W22: MOV R4,#125
W33: MOV R0,248
DJNZ R0,$
DJNZ R4,W33
DJNZ R7,W22
DJNZ R1,DELAY3
RET
TABLE00:;频率表
DW64260,64400,64524,64580;简码值低音5,低音6,低音7,1
DW64684,64777,64820,64898;简码值2,3,4,5
DW64968,65030,65058,65110;简码值6,7,高音1,高音
DW65157,65178,65217;简码值高音3,高音4,高音5
;--------------------------------------------------------------------
;第一首《我和你》
;--------------------------------------------------------------------
TABLE10:DB64H,82H,42H,48H
DB54H,64H,18H
DB44H,54H,64H,84H
DB5CH
DB64H,84H,44H,04H,42H
DB54H,64H,28H
DB54H,14H,54H,64H
DB4CH
DB98H,88H
DB98H,48H
DB64H,24H,64H,84H
DB5CH
DB64H,82H,42H,48H
DB54H,64H,28H
DB54H,14H,54H,34H
DB4CH
DB00H
;--------------------------------------------------------------------
;第二首《万水千山总是情》
;--------------------------------------------------------------------
TABLE20: DB64H,74H,84H,04H,82H,94H,84H,6CH
DB54H,44H,04H,62H,54H,44H,2CH
DB24H,18H,44H,54H,64H,84H,94H,64H,5CH
DB64H,74H,84H,04H,82H,94H,84H,6CH
DB54H,44H,04H,62H,54H,44H,2CH
DB24H,18H,44H,64H,54H,04H,42H,24H,44H,4CH
DB64H,84H,9CH,0A4H,94H,74H,84H,04H,92H,8CH,64H,88H
DB64H,84H,9CH,0A4H,0A4H,94H,84H,64H,5CH
DB64H,74H,84H,04H,82H,94H,84H,6CH
DB54H,44H,04H,62H,54H,44H,2CH
DB24H,18H,44H,64H,54H,42H,24,44H,4CH
DB00H
;--------------------------------------------------------------------
;第三首《送别》
;--------------------------------------------------------------------
TABLE30:DB84H,62H,82H,0B8H
DB94H,0B2H,92H,88H
DB84H,42H,52H,64H,52H,44H
DB5CH
DB84H,62H,82H,0B4H,04H,82H
DB94H,0B4H,88H
DB84H,52H,62H,74H,04H,32H
DB4CH
DB94H,0B4H,0B8H
DB0A4H,92H,0A2H,0B8H
DB92H,0A2H,0B2H,92H,92H,82H,62H,42H
DB5CH
DB84H,62H,82H,0B4H,04H,0A2H
DB94H,0B4H,88H
DB84H,52H,62H,74H,04H,32H
DB4CH
DB00H
;--------------------------------------------------------------------
;第四首《北京欢迎您》
;--------------------------------------------------------------------
TABLE40:DB62H,82H,62H,52H,12H
DB62H,52H,12H,64H
DB62H,52H,22H,42H
DB62H,54H
DB52H,42H,22H,42H
DB52H,62H,82H,52H
DB62H,92H,82H,12H
DB52H,44H
DB52H,42H,22H,42H
DB52H,62H,82H,52H
DB62H,92H,82H,82H
DB68H
DB52H,62H,52H,42H
DB82H,92H,64H
DB22H,62H,64H
DB54H,64H
DB64H,84H
DB0B2H,82H,94H
DB02H,92H,82H,62H
DB62H,82H,88H
DB00H
END你知道,做完这个题目,需要多少时间吗?
要画图,要写程序,还要写报告。这是一份完成的毕业设计吗?工作量有多大?
还用汇编写程序?行,你慢慢等吧,祝你好梦成真。你要先有多首歌曲的转化为代码曲库
其他还是比较容易的追问

曲库比较好找,就是仿真图和汇编语言不好写。本回答被网友采纳
用80c51单片机设计程序制作一个电子音乐播放器


用蜂鸣器吗?如果是的话网上资料很多啊
一首能弄出来那多首是没问题的,在内存能容纳的范围内.不会啊详细的说说


上一篇: 下一篇: