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

          新聞中心

          EEPW首頁 > 電源與新能源 > 設(shè)計(jì)應(yīng)用 > 利用MAXQ3210產(chǎn)生壓電信號(hào)

          利用MAXQ3210產(chǎn)生壓電信號(hào)

          作者: 時(shí)間:2011-04-15 來源:網(wǎng)絡(luò) 收藏
          ;; Play Middle C for one second.move LC[1], #261 ; Outer loop counter = 261 cycles (1s * 261Hz)middleC:move PO0.0, #1 ; Switch output high.move LC[0], #6839 ; Half period : (1/261Hz) / (1/3.57MHz) / 2djnz LC[0], $ ; Decrement and jump, if not zero, to current ; instruction.move PO0.0, #0 ; Switch output low.move LC[0], #6839 ; Half period : (1/261Hz) / (1/3.57MHz) / 2djnz LC[0], $ ; Decrement and jump if not zero to current ; instruction.djnz LC[1], middleC ; Decrement and jump, if not zero, to top of loop.

          通過改變循環(huán)計(jì)數(shù)器LC[0]裝載的數(shù)值來改變輸出頻率(對應(yīng)于的音符)。通過改變循環(huán)計(jì)數(shù)器LC[1]裝載的數(shù)值來改變音符持續(xù)時(shí)間。把這些代碼打包到一個(gè)簡單宏中,定義幾個(gè)常數(shù),就很容易播放一小段音樂的代碼。

          本文引用地址:http://www.ex-cimer.com/article/179206.htm
          #define NOTE_C     261#define NOTE_C_SH  277#define NOTE_D_FL  277#define NOTE_D     294#define NOTE_D_SH  311#define NOTE_E_FL  311#define NOTE_E     330#define NOTE_F     349#define NOTE_F_SH  370#define NOTE_G_FL  370#define NOTE_G     392#define EIGHTH     1       ; 120 beats per minute, 4/4 time#define QUARTER    2       ; 120 beats per minute, 4/4 time#define QUARTERDOT 3       ; 120 beats per minute, 4/4 time#define HALF       4       ; 120 beats per minute, 4/4 time#define WHOLE      8       ; 120 beats per minute, 4/4 timeplay macro note, durationlocal L1, L2move    HRNC,  #1move    LC[1], #(note * duration / 8)L1:move    PO0.0, #1         ; Switch output high.move    LC[0], #(1785000 / note)djnz    LC[0], $          ; Decrement and jump, if not zero, to current ;    instruction.move    PO0.0, #0         ; Switch output low.move    LC[0], #(1785000 / note)djnz    LC[0], $          ; Decrement and jump, if not zero, to current ;    instruction.djnz    LC[1], L1         ; Decrement and jump, if not zero, to top of loop.move    HRNC,  #1move    LC[1], #50        ; 50ms of silenceL2:move    LC[0], #3570      ; 1ms (inner loop)  djnz    LC[0], $djnz    LC[1], L2endm
          				
                      
                          
          			
          							

          評論


          相關(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); })();