完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
yfh equ 30h ;音符高位
yfl equ 31h ;音符低位 jp equ 32h ;节拍 yyd equ 33h ; yf equ 34h ; org 0000h ajmp main ;--------------定时中断程序 org 000bh cpl p2.1 mov th0,yfh mov tl0,yfl reti ;--------------主程序 org 0030h main: setb p2.1 mov yyd, #00h mov tmod,#11h setb EA setb ET0 setb TR1 setb TR0 music: mov dptr,#table2 ;取出音符,并存入yf单元 mov a,yyd movc a,@a+dptr cjne a,#00h,music1;判断音乐是否结束,结束复位 ajmp main music1: dec a rl a mov yf,a mov a,yyd;指向节拍 inc a mov yyd,a mov dptr,#table1 ;取出音符初值,并存入yfh,yfl单元 mov a,yf movc a,@a+dptr mov yfh,a mov a,yf inc a movc a,@a+dptr mov yfl,a mov dptr,#table2 mov a,yyd;取出音节,并存入jp movc a,@a+dptr mov jp,a mov th0,yfh;送入音符初值 mov tl0,yfl mov a,yyd ;指向下一音符 inc a mov yyd,a lcall delay nop ljmp music delay: mov r2,jp del4: mov r1,#3 del3: mov th1,#3ch mov tl1,#0b0h del1: ***c tf1,del2 ;查询定时时间是否到 ajmp del1 del2: djnz r1,del3 djnz r2,del4 ret table1: db 0f8h,8ch,0f9h,5ch,0fah,14h,0fah,67h,0fbh,04h,0fbh,90h,0fch,0ch DB 0fch,44h,0fch,0b6h,0fdh,09h,0fdh,34h,0fdh,82h,0fdh,0c8h,0feh,06h DB 0feh,22h,0feh,56h,0feh,8ch,0feh,9ah,0feh,0c1h,0feh,0e4h,0ffh,03h table2: ;歌曲---音节表 /*db 01h,04h,02h,04h,03h,04h,04h,04h,05h,04h,06h,04h,07h,04h ;歌曲表 db 08h,04h,09h,04h,0ah,04h,0bh,04h,0ch,04h,0dh,04h,0eh,04h db 0fh,04h,10h,04h,11h,04h,12h,04h,13h,04h,14h,04h,15h,06h db 00h*/ /*乐曲---心太软 db 0ch,02h,0ch,02h,0ah,02h,0dh,04h,0ch,02h,0ah,06h,0ah,04h,09h,02h,08h,02h,08h,04h,08h,02h db 0fh,02h,0fh,02h,0fh,02h,0fh,02h,0dh,02h,0ch,04h,0ah,02h,0dh,02h,0ch,06h*/ ;乐曲---老鼠爱大米 /*db 0ah,02h,09h,01h,08h,01h,08h,04h,0ah,02h,09h,01h,08h,01h,08h,04h,0ah,02h,09h,02h db 0ah,02h,01h,02h,0ah,02h,0dh,01h,0ch,01h,0ch,04h,0ah,01h,0ch,01h,0dh,02h,0dh,01h,0ch,01h,0ch,02h db 0dh,01h,0ch,01h,0ch,04h,0ah,01h,09h,01h,08h,02h,09h,02h,09h,01h,0ah,01h,09h,02h,08h,01h,09h,01h,09h,04h */ ;乐曲---国歌 db 05h,02h,08h,06h,08h,02h,08h,02h,08h,02h,05h,02h,06h,01h,07h,01h,08h,04h,08h,04h db 0ah,02h,08h,02h,09h,01h,0ah,01h,0ch,04h,0ch,04h,0ah,02h,0ah,01h,08h,02h,0ah,02h db 0ch,02h,0ah,01h,09h,04h,09h,08h,0dh,04h,0ch,04h,09h,04h,0ah,04h,0ch,02h,0ah,02h db 0ch,02h,0ah,02h,09h,01h,0ah,01h,08h,04h,0ah,04h,05h,02h,0dh,01h,08h,02h,08h,02h db 0ah,02h,0ah,01h,0ch,02h,0ch,02h,09h,02h,09h,01h,09h,01h,06h,04h,09h,04h,05h,02h db 08h,04h,08h,02h,0ah,04h,0ah,02h,0ch,08h,08h,02h,0ah,01h,0ch,02h,0ch,02h,0dh,04h db 0ch,04h,0ah,02h,08h,01h,0ch,02h,0ch,01h,0ch,01h,0ah,03h,08h,03h,05h,04h,08h,04h db 0ah,02h,08h,01h,0ch,02h,0ch,01h,0ch,01h,0ah,03h,08h,03h,05h,04h,08h,04h,05h,04h db 08h,04h,05h,04h,08h,04h,08h,04h end |
|
相关推荐
1个回答
|
|
已解决,大家可忽略此贴
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
298 浏览 1 评论
《DNESP32S3使用指南-IDF版_V1.6》第二十六章 INFRARED_RECEPTION实验
309 浏览 0 评论
826 浏览 0 评论
求助一下关于51系列单片机的Timer0的计时问题,TH0、TL0+1的时间是怎么算的?
1911 浏览 2 评论
【RA-Eco-RA4E2-64PIN-V1.0开发板试用】开箱+Keil环境搭建+点灯+点亮OLED
1427 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
12031 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 05:52 , Processed in 0.521371 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号