新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 跑馬燈及音樂(lè)盒的匯編程序

跑馬燈及音樂(lè)盒的匯編程序

作者: 時(shí)間:2012-10-20 來(lái)源:網(wǎng)絡(luò) 收藏
;蜂鳴器就使用哪種小的無(wú)源的有源的5v蜂鳴器都可以,經(jīng)過(guò)試驗(yàn)發(fā)現(xiàn)用無(wú)源的效果更好,接在p1.2口,最好用一個(gè)三極管放大一下電流,晶振用12兆的.
ORG 0000HLJMP STARTORG 000BHINC 20H ;中斷服務(wù),中斷計(jì)數(shù)器加1MOV TH0,#0D8HMOV TL0,#0EFH ;12M晶振,形成10毫秒中斷RETISTART:MOV SP,#50HMOV TH0,#0D8HMOV TL0,#0EFHMOV TMOD,#01HMOV IE,#82HMu: Mov  p3,#0ffhSETB P1.2lcall   keyMUSIC0:NOPMOV 20H,#00H ;中斷計(jì)數(shù)器清0MOV B,#00H ;表序號(hào)清0MUSIC1:NOPCLR AMOVC A,@A+DPTR ;查表取代碼MOV  P3,AJZ  MUJZ END0 ;是00H,則結(jié)束CJNE A,#0FFH,MUSIC5LJMP MUSIC3MUSIC5:NOPMOV R6,AINC DPTRMOV A,BMOVC A,@A+DPTR ;取節(jié)拍代碼送R7MOV R7,ASETB TR0 ;啟動(dòng)計(jì)數(shù)MUSIC2:NOPCPL P1.2MOV A,R6MOV R3,ALCALL DELMOV A,R7CJNE A,20H,MUSIC2 ;中斷計(jì)數(shù)器(20H)=R7否?;不等,則繼續(xù)循環(huán)MOV 20H,#00H ;等于,則取下一代碼INC DPTR; INC BLJMP MUSIC1MUSIC3:NOPCLR TR0 ;休止100毫秒MOV R2,#0DHMUSIC4:NOPMOV R3,#0FFHLCALL DELDJNZ R2,MUSIC4INC DPTRLJMP MUSIC1END0:NOPMOV R2,#64H ;歌曲結(jié)束,延時(shí)1秒后繼續(xù)MUSIC6:MOV R3,#00HLCALL DELDJNZ R2,MUSIC6LJMP  muDEL:NOPDEL3: MOV R4,#02HDEL4: NOPDJNZ R4,DEL4NOPDJNZ R3,DEL3RETKey:Key1:Mov  a,P2Mov  P0,aCjne  a,#0feh,key2Mov  dptr,#mu_tab1;;表頭地址送DPTRLjmp  MUSIC0Key2:Mov  a,P2Mov  P0,aCjne  a,#0fdh,key3Mov  dptr,#mu_tab2 ;;表頭地址送DPTRLjmp  MUSIC0Key3:Sjmp  keyNOPMu_tab1:db 26h,20h,20h,20h,20h,20h,26h,10h,20h,10h,20h,80h,26h,20h,30h,20hdb 30h,20h,39h,10h,30h,10h,30h,80h,26h,20h,20h,20h,20h,20h,1ch,20hdb 20h,80h,2bh,20h,26h,20h,20h,20h,2bh,10h,26h,10h,2bh,80h,26h,20hdb 30h,20h,30h,20h,39h,10h,26h,10h,26h,60h,40h,10h,39h,10h,26h,20hdb 30h,20h,30h,20h,39h,10h,26h,10h,26h,80h,26h,20h,2bh,10h,2bh,10hdb 2bh,20h,30h,10h,39h,10h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,20hdb 20h,10h,20h,10h,2bh,10h,26h,30h,30h,80h,18h,20h,18h,20h,26h,20hdb 20h,20h,20h,40h,26h,20h,2bh,20h,30h,20h,30h,20h,1ch,20h,20h,20hdb 20h,80h,1ch,20h,1ch,20h,1ch,20h,30h,20h,30h,60h,39h,10h,30h,10hdb 20h,20h,2bh,10h,26h,10h,2bh,10h,26h,10h,26h,10h,2bh,10h,2bh,80hdb 18h,20h,18h,20h,26h,20h,20h,20h,20h,60h,26h,10h,2bh,20h,30h,20hdb 30h,20h,1ch,20h,20h,20h,20h,80h,26h,20h,30h,10h,30h,10h,30h,20hdb 39h,20h,26h,10h,2bh,10h,2bh,20h,2bh,40h,40h,10h,40h,10h,20h,10hdb 20h,10h,2bh,10h,26h,30h,30h,80h,00Hmu_tab2:DB      18H,     30H,     1CH,     10HDB      20H,     40H,     1CH,     10H     DB      18H,     10H,     20H,     10HDB      1CH,     10H,     18H,     40HDB      1CH,     20H,     20H,     20HDB      1CH,     20H,     18H,     20H     DB      20H,     80H,     0FFH,    20HDB      30H,     1CH,     10H  ,   18HDB      20H,     15H,     20H ,    1CHDB      20H,     20H,     20H ,    26HDB      40H,     20H ,    20H ,    2BHDB      20H,     26H,     20H ,    20H     DB      20H,     30H ,    80H ,    0FFHDB      20H,     20H,     1CH ,    10HDB      18H,     10H,     20H ,    20HDB      26H,     20H ,    2BH ,    20HDB      30H,     20H ,    2BH ,    40HDB      20H,     20H  ,   1CH  ,   10HDB      18H,     10H,     20H,     20HDB      26H,     20H ,    2BH,     20HDB      30H,     20H,     2BH ,    40HDB      20H,     30H,     1CH ,    10HDB      18H,     20H ,    15H ,    20HDB      1CH,     20H ,    20H ,    20HDB      26H,     40H,     20H ,    20H     DB      2BH,     20H,     26H ,    20H     DB      20H,     20H,     30H ,    80HDB      20H,     30H,     1CH ,    10HDB      20H,     10H,     1CH ,    10HDB      20H,     20H,     26H  ,   20HDB      2BH,     20H,     30H  ,   20HDB      2BH,     40H,     20H   ,  15HDB      1FH,     05H,     20H    , 10HDB      1CH,     10H,     20H ,    20HDB      26H,     20H,     2BH ,    20HDB      30H,     20H,     2BH ,    40HDB      20H,     30H,     1CH  ,   10HDB      18H,     20H ,    15H  ,   20HDB      1CH,     20H ,    20H  ,   20HDB      26H,     40H,     20H  ,   20HDB      2BH,     20H,     26H   ,  20HDB      20H,     20H,     30H,     30H      DB      20H,     30H,     1CH,     10HDB      18H,     40H,     1CH,     20HDB      20H,     20H,     26H,     40HDB      13H,     60H,     18H ,    20HDB      15H,     40H,     13H ,    40HDB      18H,     80H,     00HEND
蜂鳴器相關(guān)文章:蜂鳴器原理


評(píng)論


相關(guān)推薦

技術(shù)專(zhuān)區(qū)

關(guān)閉