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

          新聞中心

          S3C2440-蜂鳴器

          作者: 時間:2016-12-02 來源:網(wǎng)絡(luò) 收藏


          #define rGPBCON (*(volatile unsigned *)0x56000010)
          #define rGPBDAT (*(volatile unsigned *)0x56000014)
          #define rGPBUP (*(volatile unsigned *)0x56000018)
          #define rTCFG0 (*(volatile unsigned *)0x51000000)
          #define rTCFG1 (*(volatile unsigned *)0x51000004)
          #define rTCNTB0 (*(volatile unsigned *)0x5100000C)
          #define rTCMPB0 (*(volatile unsigned *)0x51000010)
          #define rTCON (*(volatile unsigned *)0x51000008)

          int Main(){
          rGPBCON &= 0xfffffc;
          rGPBCON |= 0x2;
          rTCFG0 &= "0xff;
          rTCFG0 |= 0x64;
          rTCFG1 &= "0xf;
          rTCFG1 |= 0x3;
          rTCNTB0 = 0x7530;
          rTCMPB0 = rTCNTB0>>1;
          rTCON &= "0x1f;
          rTCON |= (0x1)|(0x1<<1)|(0x1<<3);
          rTCON &= "2;
          while(1);
          return 0;
          }

          使用定時器產(chǎn)生中斷使IO電平翻轉(zhuǎn),控制蜂鳴器:

          定時器注意設(shè)置rINTMSK開中斷,并在中斷處理程序中清除中斷請求位。rSRCPND |= 0x1<<10;rINTPND |= 0x1<<10;清除rINTPND通過設(shè)置相應為1進行清除。rSTCPND是向相應位寫數(shù)據(jù)清除。如果不清除,會一直響應這個中斷。在Main函數(shù)中清一下是為了防止以前這個位申請中斷,所以清一下,以防萬一。定時器接在APB總線上,所以用PCLK時鐘。在這里我設(shè)預分頻為0x64,除法器為16,rTCNTB0為0x7a12,所以 50M/0x64/16/0x7a12為1HZ,所以中斷周期為1s,所以每一秒蜂鳴器響一下,然后隔一秒,然后再響。

          #define rGPBCON (*(volatile unsigned *)0x56000010)
          #define rGPBDAT (*(volatile unsigned *)0x56000014)
          #define rGPBUP (*(volatile unsigned *)0x56000018)
          #define rSRCPND (*(volatile unsigned *)0x4A000000)
          #define rINTPND (*(volatile unsigned *)0x4A000010)
          #define rTCFG0 (*(volatile unsigned *)0x51000000)
          #define rTCFG1 (*(volatile unsigned *)0x51000004)
          #define rTCNTB0 (*(volatile unsigned *)0x5100000C)
          #define rTCON (*(volatile unsigned *)0x51000008)
          #define rINTMSK (*(volatile unsigned *)0x4A000008)
          #define U32 unsigned int
          #define _ISR_STARTADDRESS 0x33ffff00
          #define pISR_TIMER0 (*(unsigned *)(_ISR_STARTADDRESS+0x48))
          int count;
          void __irq Timer0_ISR(void){
          rSRCPND |= 0x1<<10;
          rINTPND |= 0x1<<10;
          count++;
          if(count %2 == 1)
          rGPBDAT |= 0x01;
          else
          rGPBDAT &= 0xfe;
          if(count == 1000)
          count = 0;
          }

          int Main(){
          count = 0;
          rGPBCON &= 0xfffffc;
          rGPBCON |= 0x1;
          rGPBDAT &= 0xffe;
          rGPBUP &= 0xfe;
          pISR_TIMER0 = (U32)Timer0_ISR;
          rSRCPND |= 0x1<<10;
          rINTPND |= 0x1<<10;
          rINTMSK &= "(0x1<<10);
          rTCFG0 &= "0xff;
          rTCFG0 |= 0x64;
          rTCFG1 &= "0xf;
          rTCFG1 |= 0x3;
          rTCNTB0 = 0x7a12;
          rTCON &= "0x1f;
          rTCON |= 0xb;
          rTCON &= "0x2;
          while(1);
          return 0;
          }

          上一頁 1 2 下一頁

          關(guān)鍵詞: S3C2440蜂鳴器PW

          評論


          技術(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); })();