<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機音樂程序設(shè)計

          單片機音樂程序設(shè)計

          作者: 時間:2012-09-02 來源:網(wǎng)絡(luò) 收藏

          隨便找一個仿真機或者什么實驗板,只要能工作的就行,將程序輸入,運行,然后找個音箱(你計算機旁邊應(yīng)當(dāng)就有一對吧)撥出插頭,插頭的前端接在P1。0上,后面部分找根線接的地,就應(yīng)當(dāng)有聲了,然后怎么改進硬件連接就是你的事了。。。。

          本文引用地址:http://www.ex-cimer.com/article/170934.htm

          程序匯編代碼代碼1 -------------Voice.asm--------------------------

          ORG 0000H
          LJMP START
          ORG 000BH
          INC 20H ;中斷服務(wù),中斷計數(shù)器加1
          MOV TH0,#0D8H
          MOV TL0,#0EFH ;12M晶振,形成10毫秒中斷
          RETI
          START:
          MOV SP,#50H
          MOV TH0,#0D8H
          MOV TL0,#0EFH
          MOV TMOD,#01H
          MOV IE,#82H
          MUSIC0:
          NOP
          MOV DPTR,#DAT ;表頭地址送DPTR
          MOV 20H,#00H ;中斷計數(shù)器清0
          MOV B,#00H ;表序號清0
          MUSIC1:
          NOP
          CLR A
          MOVC A,@A+DPTR ;查表取代碼
          JZ END0 ;是00H,則結(jié)束
          CJNE A,#0FFH,MUSIC5
          LJMP MUSIC3
          MUSIC5:
          NOP
          MOV R6,A
          INC DPTR
          MOV A,B
          MOVC A,@A+DPTR ;取節(jié)拍代碼送R7
          MOV R7,A
          SETB TR0 ;啟動計數(shù)
          MUSIC2:
          NOP
          CPL P1.0
          MOV A,R6
          MOV R3,A
          LCALL DEL
          MOV A,R7
          CJNE A,20H,MUSIC2 ;中斷計數(shù)器(20H)=R7否?
          ;不等,則繼續(xù)循環(huán)
          MOV 20H,#00H ;等于,則取下一代碼
          INC DPTR
          ; INC B
          LJMP MUSIC1
          MUSIC3:
          NOP
          CLR TR0 ;休止100毫秒
          MOV R2,#0DH
          MUSIC4:
          NOP
          MOV R3,#0FFH
          LCALL DEL
          DJNZ R2,MUSIC4
          INC DPTR
          LJMP MUSIC1
          END0:
          NOP
          MOV R2,#64H ;歌曲結(jié)束,延時1秒后繼續(xù)
          MUSIC6:
          MOV R3,#00H
          LCALL DEL
          DJNZ R2,MUSIC6
          LJMP MUSIC0
          DEL:
          NOP
          DEL3:
          MOV R4,#02H
          DEL4:
          NOP
          DJNZ R4,DEL4
          NOP
          DJNZ R3,DEL3
          RET
          NOP
          DAT:
          db 26h,20h,20h,20h,20h,20h,26h,10h,20h,10h,20h,80h,26h,20h,30h,20h
          db 30h,20h,39h,10h,30h,10h,30h,80h,26h,20h,20h,20h,20h,20h,1ch,20h
          db 20h,80h,2bh,20h,26h,20h,20h,20h,2bh,10h,26h,10h,2bh,80h,26h,20h
          db 30h,20h,30h,20h,39h,10h,26h,10h,26h,60h,40h,10h,39h,10h,26h,20h
          db 30h,20h,30h,20h,39h,10h,26h,10h,26h,80h,26h,20h,2bh,10h,2bh,10h
          db 2bh,20h,30h,10h,39h,10h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,20h
          db 20h,10h,20h,10h,2bh,10h,26h,30h,30h,80h,18h,20h,18h,20h,26h,20h
          db 20h,20h,20h,40h,26h,20h,2bh,20h,30h,20h,30h,20h,1ch,20h,20h,20h
          db 20h,80h,1ch,20h,1ch,20h,1ch,20h,30h,20h,30h,60h,39h,10h,30h,10h
          db 20h,20h,2bh,10h,26h,10h,2bh,10h,26h,10h,26h,10h,2bh,10h,2bh,80h
          db 18h,20h,18h,20h,26h,20h,20h,20h,20h,60h,26h,10h,2bh,20h,30h,20h
          db 30h,20h,1ch,20h,20h,20h,20h,80h,26h,20h,30h,10h,30h,10h,30h,20h
          db 39h,20h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,10h,40h,10h,20h,10h
          db 20h,10h,2bh,10h,26h,30h,30h,80h,00H

          END

          程序匯編代碼代碼2 -------------Voice1.asm--------------------------

          ;標(biāo)題 '八月桂花香'發(fā)聲程序
          ;摘要 詳見'無線電'92年3期
          ;作者 周振安
          ORG 0000H
          LJMP START
          ORG 000BH
          INC 20H ;中斷服務(wù),中斷計數(shù)器加1
          MOV TH0,#0D8H
          MOV TL0,#0EFH ;12M晶振,形成10毫秒中斷
          RETI
          START:
          MOV SP,#50H
          MOV TH0,#0D8H
          MOV TL0,#0EFH
          MOV TMOD,#01H
          MOV IE,#82H
          MUSIC0:
          NOP
          MOV DPTR,#DAT ;表頭地址送DPTR
          MOV 20H,#00H ;中斷計數(shù)器清0
          MOV B,#00H ;表序號清0
          MUSIC1:
          NOP
          CLR A


          上一頁 1 2 下一頁

          關(guān)鍵詞: 程序設(shè)計 音樂 單片機

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();