色婷婷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ò) 收藏
          SPKEQUP3.7; 蜂鳴器所在端口

          COUNT50EQU39H
          SECEQUR0
          MINEQUR1
          SEGEQUP2
          NUMEQUP0
          SEG7EQU30H
          SEG6EQU31H
          SEG5EQU32H
          SEG4EQU33H
          SEG3EQU36H
          SEG1EQU 3AH

          DLAYEQU34H
          H_CNT1EQU37H
          H_CNT2EQU38H
          FLAGBIT 00H

          KEYVALEQU40H
          XUN1EQU41H
          XUN2EQU42H
          MUSICEQU43H
          ORG0000H
          LJMPMAIN
          ORG0003H
          LJMP PLY_PAU
          ORG0013H
          LJMP STOP
          ORG000BH;定時(shí)0中斷服務(wù)程序
          LJMP COUNT

          ;------------------------------------------------------
          ORG100H
          MAIN:MOVSP,#60H;初始化堆棧
          MOVSEC,#0H;初始化秒
          MOVMIN,#0H;初始化分
          MOVCOUNT50,#50;一秒定時(shí)
          CLRFLAG



          MOVIE,#8FH
          MOVTMOD,#11H
          MOVTH0,#0A5H
          MOVTL0,#0FFH
          MOVTH1,#0EDH
          MOVTL1,#0FFH
          SETBIT0
          SETBIT1

          MOVKEYVAL,#00H
          MOVMUSIC,#01H
          MOVDPTR,#TABLE1
          MOV37H,#0FFH
          MOV38H,#05H

          ;**************歡迎界面**********************
          HELLO:MOV30H,#7FH
          MOV31H,#0BFH
          MOV32H,#0DFH
          MOV33H,#0EFH
          MOV36H,#0F7H
          MOV 3AH,#0FDH
          MOVP2,SEG3;H
          MOVP0,#89H
          LCALL LDELAY


          MOVP2,SEG4;E
          MOVP0,#86H
          LCALL LDELAY


          MOVP2,SEG5;L
          MOVP0,#0C7H
          LCALL LDELAY


          MOVP2,SEG6;L
          MOVP0,#0C7H
          LCALL LDELAY

          MOVP2,SEG7;O
          MOVP0,#0C0H
          LCALL LDELAY

          MOVA,KEYVAL
          JNZKEYJDG
          DJNZ H_CNT1, HELLO
          DJNZ H_CNT2,HELLO
          ;==========================================================
          SETBTR0
          LJMP SING
          KEYGET:LCALL KEY
          MOVA,KEYVAL
          JZKEYGET
          KEYJDG:CJNE A,#12H,SECON
          FIRST1:MOVDPTR,#TABLE1
          MOVMUSIC,#01H
          MOVKEYVAL,#00H
          ;SETBFLAG
          MOVSEC,#00H
          MOVMIN,#00H
          MOVCOUNT50,#50
          SETBTR0

          LJMP SING
          SECON:CJNE A,#11H,THIR
          SECON1:MOVDPTR,#TABLE2
          MOVMUSIC,#02H
          MOVKEYVAL,#00H
          ;SETBFLAG
          MOVSEC,#00H
          MOVMIN,#00H
          MOVCOUNT50,#50
          SETBTR0
          LJMP SING
          THIR:CJNE A,#0FH,FORTH
          THIR1:MOVDPTR,#TABLE3
          MOVMUSIC,#03H
          MOVKEYVAL,#00H
          ;SETBFLAG
          MOVSEC,#00H
          MOVMIN,#00H
          MOVCOUNT50,#50
          SETBTR0
          LJMP SING
          FORTH:CJNE A,#0BH,UP
          FORTH1:MOVDPTR,#TABLE4
          MOVMUSIC,#04H
          MOVKEYVAL,#00H
          ;SETBFLAG
          MOVSEC,#00H
          MOVMIN,#00H
          MOVCOUNT50,#50
          SETBTR0
          LJMP SING
          UP:CJNE A,#02H,DOWN
          MOVKEYVAL,#00H
          MOVR5,MUSIC
          CJNE R5,#00H,N1
          LJMP KEYGET
          N1:CJNE R5,#01H,N2
          LJMP FORTH1
          N2:CJNE R5,#02H,N3
          LJMP FIRST1
          N3:CJNE R5,#03H,N4
          LJMP SECON1
          N4:LJMP THIR1
          DOWN:; LCALL VLDELAY
          MOVR5,MUSIC
          MOVKEYVAL,#00H
          CJNE R5,#00H,M1
          LJMP KEYGET
          M1:CJNE R5,#01H,M2
          LJMP SECON1
          M2:CJNE R5,#02H,M3
          LJMP THIR1
          M3:CJNE R5,#03H,M4
          LJMP FORTH1
          M4:LJMP FIRST1
          ;-----------------------------------------------------------
          KEY: PUSH ACC
          MOVP1,#0F0H;置列線為0,行線為1 ;^^^^^^^^^^^^
          MOVA,P1
          ANLA,#0F0H
          MOVB,A
          MOVP1,#0FH;置列線為1,行線為0
          MOVA,P1
          ANLA,#0FH
          ORLA,B
          CJNE A,#0FFH,UUU
          AJMP QICH
          UUU:CLRC
          SUBB A,#0DCH
          JNCHAHA
          QICH:CLRA

          HAHA:MOVKEYVAL,A

          POP ACC
          RET
          ;-------------------------------------------------------------



          ;-------------------------------------------------------------
          ;**************定時(shí)中斷服務(wù)程序***********************
          COUNT:MOVTH0,#0A5H
          MOVTL0,#0FFH
          LCALL KEY
          JNBFLAG,RETURN
          DJNZ COUNT50,RETURN ;是否到一秒
          ;*****一秒處理****************
          MOVCOUNT50,#50
          INCSEC
          CJNE SEC,#60,RETURN
          MOVSEC,#0H
          INCMIN
          CJNE MIN,#100,RETURN ;一百分鐘以后自動(dòng)清零
          MOVMIN,#00H
          RETURN: LCALL DISPLAY
          RETI
          ;**************************************************
          ;**************顯示子程序*******************
          DISPLAY:PUSHACC
          PUSHB
          PUSH DPH
          PUSH DPL



          MOVA,MIN
          MOVB,#0AH
          DIVAB
          MOVSEG,SEG4
          LCALL TODIS
          LCALL DELAY

          MOVSEG,SEG5
          MOVA,B
          MOVDPTR,#TABLE
          MOVC A,@A+DPTR
          ANL A,#7FH
          MOVNUM,A
          LCALL DELAY


          MOVA,SEC
          MOVB,#10
          DIVAB
          MOVSEG,SEG6
          LCALL TODIS
          LCALL DELAY


          MOVSEG,SEG7
          MOVA,B
          LCALL TODIS
          LCALL DELAY

          MOVA,MUSIC
          MOVSEG,SEG1
          LCALL TODIS


          POP DPL
          POP DPH
          POPB
          POPACC

          RET


          上一頁 1 2 下一頁

          評論


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

          關(guān)閉