色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 基于51單片機(jī)的數(shù)字音樂盒C語言驅(qū)動(dòng)程序

          基于51單片機(jī)的數(shù)字音樂盒C語言驅(qū)動(dòng)程序

          作者: 時(shí)間:2016-11-28 來源:網(wǎng)絡(luò) 收藏

          ;******數(shù)字到字型*****************
          TODIS: PUSH DPH
          PUSH DPL

          MOVDPTR,#TABLE
          MOVC A,@A+DPTR
          MOVNUM,A

          POP DPL
          POP DPH

          RET
          ;******************************************
          ;*********短延時(shí)子程序1.38毫秒*****************
          DELAY:PUSHACC

          MOVDLAY,#01H
          LOOP:MOVACC,#0FFH
          DJNZ ACC,$
          DJNZ DLAY,LOOP

          POPACC
          RET
          ;******************************************
          ;*********長延時(shí)子程序24.9毫秒*****************
          LDELAY:PUSHACC

          MOVDLAY,#01H
          LLOOP:MOVACC,#0FDH
          DJNZ ACC,$
          DJNZ DLAY,LLOOP

          POPACC
          RET
          ;******************************************


          ;****************外部中斷0服務(wù)程序(播放/暫停)***************************
          PLY_PAU:
          SETBTR0

          CPL FLAG
          RETI
          ;***************外部中斷1服務(wù)程序(停止)***********************************
          STOP:

          MOVSEC,#00H
          MOVMIN,#00H
          MOVCOUNT50,#50
          CLR FLAG
          MOV R3,#02H
          ; CLR TR0;*******
          RETI
          ;**************************************************

          ;==============================================================
          SING:MOVR3,#02H
          NEXT:
          MOVA,KEYVAL
          JZPPB
          LJMPKEYJDG
          PPB:JNBFLAG,NEXT ;?

          MOV A,R3

          CJNEA,#00H,XIA
          INCDPH
          XIA:MOVC A,@A+DPTR ;?
          JZSTART
          MOVR7,A
          INCR3
          MOVA,R3
          MOVC A,@A+DPTR
          MOVR2,A
          ACALL SONG
          INCR3
          SJMP NEXT
          START:CLR FLAG
          LJMPKEYGET


          ;===============================================================================
          ;===歌曲播放子程序 ===
          SONG:PUSHDPH
          PUSHDPL
          MOVA,R2; 取出節(jié)拍
          RL A
          ; RL A
          JNZKEEP
          MOVA,#01H
          KEEP:MOVR2,A

          REPEAT:ACALL EIGHTH
          DJNZ R2,REPEAT
          SETBSPK
          MOVR6,#05H
          YU:MOVR4,0FFH
          ACALL SDELAY
          DJNZ R6,YU
          POPDPL
          POPDPH
          RET

          ;===============================================================================
          ;===產(chǎn)生1/8拍延時(shí)子程序===
          EIGHTH:CJNE R7,#20H,NEXT1
          MOVR5,15H
          Y3:MOVR4,0FAH
          Y2:MOVR6,#09H
          NOP
          Y1:DJNZ R6,Y1
          DJNZR4,Y2
          DJNZ R5,Y3
          RET
          NEXT1:MOVA,R7; 查表取出廷時(shí)參數(shù),保存到R4
          MOVDPTR,#DELAY_T
          MOVC A,@A+DPTR
          MOVR4,A
          MOVA,R7; 查表取出1/8拍周期數(shù),保存到R5
          MOVDPTR,#S_PARA
          MOVCA,@A+DPTR
          MOVR5,A
          NEXTCYC:ACALL SOUND
          DJNZ R5,NEXTCYC
          RET
          ;===============================================================================
          ;===發(fā)聲子程序 ===
          SOUND:SETBSPK
          ACALL SDELAY
          CLR SPK
          ACALL SDELAY
          RET

          ;===============================================================================
          ;===延時(shí)子程序===
          SDELAY:
          MOVA,R4; 廷時(shí)值在R4內(nèi)
          MOVXUN1,A
          XL2:MOVXUN2,#03H
          DL1:DJNZ XUN2,DL1
          DJNZ XUN1,XL2
          RET
          ;===============================================================================
          ;===1/8拍周期表===
          S_PARA:DB10H,12H,14H,16H,18H,1BH,1FH
          DB21H,24H,29H,2CH,31H,37H,3EH
          DB3FH,45H,52H,57H,62H,6EH,7BH

          ;===============================================================================
          ;===延時(shí)參數(shù)表===
          DELAY_T:DB0C3H,0AEH,9BH,92H,83H,74H,68H;00-06
          DB62H,57H,4DH,49H,41H,3AH,34H;07-0DH
          DB31H,2EH,27H,24H,20H,1DH,19H;0E-14H

          ;===============================================================================
          ;**************************************************
          TABLE:DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,88H,83H,0C6H,0A1H,86H,83H

          ;===歌曲表===
          TABLE1:DW0000H,0504H,0806H,0802H,0802H,0802H,0702H,0802H,0906H,0702H,0506H
          DW0502H,0A04H,0804H,0302H,0302H,0402H,0402H,0504H,0504H,0504H,2004H
          DW0502H,0806H,0902H,0A02H,0902H,0801H,0701H,0601H,0501H,0406H,0602H,0804H,0902H
          DW0802H,0506H,0602H,0502H,0402H,0202H,0302H,0104H,0102H,2004H
          DW0504H,0806H,0802H,0802H,0802H,0702H,0802H,0B06H,0A01H,0901H,0906H
          DW0902H,0A04H,0804H,0302H,0302H,0402H,0402H,0504H,0504H,0504H,2004H
          DW0502H,0806H,0902H,0A02H,0902H,0801H,0701H,0601H,0501H,0406H,0602H,0804H,0902H
          DW0802H,0506H,0602H,0502H,0402H,0202H,0302H,0104H,2002H
          DW0502H,0806H,0902H,0A02H,0902H,0801H,0701H,0601H,0501H,0406H,0602H,0804H,0902H
          DW0802H,0506H,0602H,0502H,0402H,0202H,0302H,0106H,2004H
          DW0000H
          TABLE2:
          DW0000H,0901H,0A01H,0B02H,0B02H,0B02H,0702H,0801H,0702H,0904H,2002H;人生路上甜苦和喜憂
          DW0801H,0702H,0702H,0502H,0701H,0502H,0403H,2004H ;

          本文引用地址:http://cafeforensic.com/article/201611/322656.htm

          DW0901H,0A01H,0B02H,0B02H,0B02H,0702H,0801H,0702H,0904H,2002HDW0801H,0702H,0701H,0501H,0501H,0702H,0803H,0802H,2004H;

          DW0901H,0801H,0102H,0701H,0801H,0701H,0501H,0501H,0401H,0401H,0902H,0901H,0902H,2001H ;DW0901H,0901H,0801H,0701H,0701H,0501H,0701H,0801H,0701H,0901H,0904H,2002H ;DW0901H,0801H,0702H,0701H,0801H,0701H,0501H,0501H,0401H,0401H,0902H,0901H,0902H,2002H ;DW0901H,0901H,0801H,0701H,0501H,0701H,0C02H,0B01H,0B04H,2004H ;

          DW0B02H,0B01H,0901H,0902H,0B02H,0C01H,0901H,0901H,0B01H,0B02H,2002H;

          DW0702H,0701H,0701H,0801H,0902H,0B01H,0B02H,0B02H,2004H;DW0C03H,0C01H,0B01H,0901H,0902H,0B01H,0C02H,0701H,0703H,2002H ;

          DW0901H,0801H,0901H,0801H,0701H,0702H,0501H,0701H,0701H,0801H,0802H,0802H,2004H;DW0B02H,0B01H,0901H,0902H,0B02H,0C01H,0901H,0901H,0B01H,0B02H,2002H;DW0702H,0E01H,0D01H,0C01H,0902H,0B01H,0B04H,2004H ;DW0C03H,0C01H,0B01H,0901H,0902H,0B01H,0C02H,0701H,0703H,2002H ;風(fēng)風(fēng)雨雨都接受
          DW0901H,0801H,0901H,0801H,0701H,0701H,0502H,0801H,0701H,0703H,0702H,2003H ;

          DW0C03H,0C01H,0B01H,0901H,0902H,0B01H,0C02H,0901H,0903H,2002H ;

          DW0901H,0801H,0901H,0B01H,0C01H,0901H,0702H,0502H,0703H,0702H,0702H,2004H ;;我一直會(huì)在你的左右
          DW0000H
          TABLE3:
          DW0000H,0902H,0902H,0A02H,0B02H,0B02H,0A02H,0902H,2002H
          DW0802H,0702H,0702H,0802H,0902H,0903H,0801H,0802H,0802H,2002H
          DW0902H,0902H,0A02H,0B02H,0B02H,0A02H,0902H,0802H,2002H
          DW0702H,0702H,0802H,0902H,0803H,0701H,0702H,0702H,2002H
          DW0802H,0802H,0902H,0702H,0802H,0901H,0A01H,0902H,0702H,0802H,0901H,0A01H,0902H,0802H,0702H,0802H,0B02H,2002H
          DW0902H,0902H,0902H,0A02H,0B02H,0B02H,0A02H,0902H,0A01H,0801H,0702H,0702H,0802H,0902H,0803H,0701H,0702H,0702H,2002H
          DW0000H
          TABLE4:
          DW0000H,0804H,0904H,0904H,0906H,0802H,0704H,0504H,0706H,0802H,0708H,0804H,0904H,0904H,0906H,0B02H,0904H,0904H,0804H,0904H
          DW 0908H,0B04H,0C04H,0C04H,0C06H,0B02H,0904H,0904H,0B04H,0C04H,0B08H,0804H,0904H,0904H,0806H,0902H,0904H,0804H,0904H,0508H
          DW 0508H,0802H,0802H,0802H,0702H,0504H,0802H,0802H,0802H,0702H,0504H,0804H,0904H,0704H,0806H,0902H,0B04H,0C02H,0C02H,0C02H,0B02H
          DW 0904H,0802H,0802H,0802H,0702H,0504H,0504H,0404H,0504H,0508H,0000H
          END


          上一頁 1 2 下一頁

          評論


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

          關(guān)閉