在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            S3C2440-蜂鳴器

            作者: 時(shí)間:2016-12-02 來(lái)源:網(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;
            }

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

            定時(shí)器注意設(shè)置rINTMSK開(kāi)中斷,并在中斷處理程序中清除中斷請(qǐng)求位。rSRCPND |= 0x1<<10;rINTPND |= 0x1<<10;清除rINTPND通過(guò)設(shè)置相應(yīng)為1進(jìn)行清除。rSTCPND是向相應(yīng)位寫數(shù)據(jù)清除。如果不清除,會(huì)一直響應(yīng)這個(gè)中斷。在Main函數(shù)中清一下是為了防止以前這個(gè)位申請(qǐng)中斷,所以清一下,以防萬(wàn)一。定時(shí)器接在APB總線上,所以用PCLK時(shí)鐘。在這里我設(shè)預(yù)分頻為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;
            }

            上一頁(yè) 1 2 下一頁(yè)

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

            評(píng)論


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

            關(guān)閉