




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、 圖1 樂曲播放器電路圖源程序清單;*; ; mcu音樂播放器 ; ;作者:耶濤 ; ;開發(fā)時間:2005年9月20日 ; ;*; org 0000h ajmp start org 000bh ajmp tim0 org 001bh reti org 0023hstart: mov r5,#00h ;初始化 mov tmod,#00010001b mov ie,#10101010b mov dptr,#tab2 ;裝第一首歌 mov 30h,dpl ;dptr低8位送30h暫存 mov 31h,dph ;dptr高8位送31h暫存start1: inc r7 ;產(chǎn)生8位隨機數(shù) mov a,#1
2、2h mov b,r7 mul ab mov p1,a ;8位隨機數(shù)由p1口輸出 mov dpl,30h mov dph,31h mov a,#00h movc a,a+dptr ;查表 mov r0,a ;音符數(shù)據(jù)送r0嶄存 mov a,#00h inc dptr movc a,a+dptr ;查表 mov r1,a ;節(jié)拍數(shù)據(jù)送r1嶄存 inc dptr mov 30h,dpl mov 31h,dph cjne a,#01h,elect ;一首歌沒結(jié)束轉(zhuǎn)elect inc r5 ;結(jié)束歌曲計數(shù)器加1 elect: jz start ;所有歌曲結(jié)束轉(zhuǎn)start循環(huán) mov a,r0 jnz
3、sing clr tr0 setb p3.7 loop1: acall delay ;調(diào)用延時子程序 djnz r1,loop1 sjmp start1 sing: mov dptr,#tab1 ;音符表首址送dptr dec r0 ;計算音符 mov a,r0 mov b,#02h mul ab mov r0,a movc a,a+dptr ;查表 mov 21h,a inc dptr mov a,r0 movc a,a+dptr mov 20h,a mov tl0,20h mov th0,21h setb tr0 ;開t0定時器 loop2: acall delay djnz r1,loo
4、p2 ajmp start1 tim0: mov tl0,20h mov th0,21h cpl p3.7 reti ;中斷返回 delay: mov r2,#70 delay1: mov r3,#252 djnz r3,$ jnb p3.4,form ;上一曲開關按下轉(zhuǎn)form jnb p3.5,next ;下一曲開關按下轉(zhuǎn)next djnz r2,delay1 ret form: clr ea ;關中斷 jnb p3.4,$ ;等待鍵釋放 cjne r5,#00h,zero ;不是第一首歌曲轉(zhuǎn)zer0 mov r5,#08h ;是第一首將最后一首歌曲裝入歌曲計數(shù)器 sjmp keywork
5、 zero: dec r5 ;歌曲向上進一首 sjmp keywork next: clr ea jnb p3.5,$ inc r5 ;歌曲下翻一首keywork: mov dptr,#tab ;將歌曲排列表裝入dptr mov a,r5 ;將r5的內(nèi)容送a rl a setb ea ;開中斷 jmp a+dptr ;根據(jù)a的內(nèi)容轉(zhuǎn)向不同歌曲 tab: ajmp music2 ajmp music3 ajmp music4 ajmp music5 music2: mov dptr,#tab2 ;第2首歌曲首址送dptr gong: mov 30h,dpl mov 31h,dph ajmp st
6、art1 music3: mov dptr,#tab3 sjmp gong music4: mov dptr,#tab4 sjmp gong music5: mov dptr,#tab5 sjmp gong ;*(音符表)*; tab1: dw 64021,64185,64331,64400,64524,64632,64732, dw 64777,64860,64934,64968,65030,65085,65134, dw 65157,65198,65235,65252,65283,65310,65335,;*(蘭花草)*;tab2: dw 0608h,0a08h,0a08h,0a08h,0
7、a18h,0908h,0808h,0908h, dw 0808h,0708h,0620h,0d08h,0d08h,0d08h,0d08h,0d18h, dw 0c08h,0a08h,0c08h,0c08h,0b08h,0a20h,0a08h,0d08h, dw 0d08h,0c08h,0a18h,0908h,0808h,0908h,0808h,0708h, dw 0610h,0310h,0308h,0808h,0808h,0708h,0618h,0a08h, dw 0908h,0808h,0708h,0508h,0620h,0908h,0808h,0708h, dw 0508h,0640h,0
8、001h;*(梁祝)*; tab3: dw 0a10h,0c08h,0d04h,0f08h,1004h,0d04h,0f04h,0c08h, dw 1308h,1504h,1404h,1304h,1104h,1304h,1018h,1008h, dw 1004h,1104h,0e08h,0d04h,0c08h,0d04h,0f08h,1008h, dw 0a08h,0f08h,0d04h,0c04h,0d04h,0f04h,0c18h,1108h, dw 1304h,0e08h,1008h,0d04h,0f04h,0c08h,0c10h,0a08h, dw 0c02h,0a08h,0c08h,
9、0d02h,0e04h,1004h,0d18h,0c04h, dw 0d04h,0f08h,1004h,1308h,1108h,1008h,1104h,1004h, dw 0f08h,0d04h,0c04h,0a10h,0f10h,0d08h,0f02h,0d04h, dw 0c04h,0a04h,0c04h,0d04h,0f04h,0c38h,0001h;*(讓我們蕩起雙槳)*;tab4: dw 0608h,0808h,0908h,0a18h,0c08h,0a08h,0808h,0910h, dw 0620h,0008h,0808h,0908h,0a08h,0c18h,0001h,0c08h
10、, dw 0d10h,0910h,0a30h,0001h,0a08h,0c08h,0d20h,0c18h, dw 0d08h,0f08h,0e04h,0d04h,0c08h,0d08h,0a10h,0004h, dw 0808h,0908h,0a18h,0c08h,0810h,0610h,0808h,0908h, dw 0a08h,0d08h,0c30h,0010h,0a20h,0d18h,0001h,0d08h, dw 0c08h,0b08h,0a10h,0001h,0920h,0a18h,0c08h,0608h, dw 0808h,0910h,0010h,0808h,0908h,0a10h
11、,0c0bh,0001h, dw 0c04h,0d10h,0f10h,0e08h,0d08h,0c08h,0a08h,0d40h, dw 0001h;*(童年)*;tab5: dw 0a08h,0c08h,0c10h,0c08h,0a08h,0d08h,0d08h,0e08h, dw 0d08h,0d08h,0d08h,0d08h,0c08h,0f10h,0f08h,0f08h, dw 0f08h,0d08h,0f08h,0d08h,0c40h,0a08h,0c08h,0c10h, dw 0c08h,0a08h,0d08h,0d08h,0e08h,0d08h,0d08h,0d08h, dw 0d08h,0c08h,0f10h,0f08h,0f08h,0f08h,0d08h,0d08h, dw 0f08h,1040h,1308h,1308h,1310h,1310h,1108h,1008h, dw 0f08h,0f10h,0d08h,0d08h,0f08h,0d08h,0f08h,1008h, dw 1008h,1008h,1008h,1
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
評論
0/150
提交評論