中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 2051的比較器模擬AD源程序(C語言)

        2051的比較器模擬AD源程序(C語言)

        作者: 時間:2011-05-17 來源:網(wǎng)絡(luò) 收藏

        2051的(C)

        本文引用地址:http://www.antipu.com.cn/article/150738.htm

        /* io分配: *
        ;* OUTPUT: *
        ;* P1.0 ...... 量輸入 *
        ;* P1.1 ...... DA輸入基準(zhǔn)電壓 *
        ;* P1.2~7..... R-2R DA電阻網(wǎng)絡(luò) *
        ;* P3.7 ...... LED 亮度輸出 *
        ;* CPU CLOCK EQU 6M */
        //xiaoqi last edit in 2001.11
        //#pragma src
        #i nclude AT89x051.h
        #i nclude stdlib.h>
        #i ncludemath.h>
        #i ncludeintrins.h>

        //變量類型標(biāo)識的宏定義,大家都喜歡這么做
        #define Uchar unsigned char
        #define Uint unsigned int

        #define Ledlight() (P3 = 0x7f)
        #define Leddark() (P3 |= 0x80)

        sbit P36 = P3^6; // 器內(nèi)部判斷腳
        sbit LED = P3^7; // 一個發(fā)光二級管觀察亮度變化

        // 內(nèi)部標(biāo)志位定義
        bit less; // 比較是否大于 1.小于,0.大于

        // 全局變量定義
        Uchar timer1, // 通用延時計數(shù)器
        timer2, // 按鍵蜂鳴器反應(yīng)定時器
        adcdata, // ad轉(zhuǎn)換變量
        pwm1; // PWM輸出比例

        // 函數(shù)列表
        void DelayMs(unsigned int number); // 毫秒延時
        void timers0(); // 在定時器中斷中做數(shù)碼管的掃描顯示(ct0)
        void Initall(void); // 系統(tǒng)初始化
        void timers1(void); // TC1定時器中斷用于掃描顯示與鍵盤
        Uchar adcread(void); // adc轉(zhuǎn)換程序

        void main(void) using 0
        {
        DelayMs(120);
        Initall();
        pwm1 = adcread();
        LED=1;
        while(1)
        {
        pwm1 = adcread();
        timer2=10;
        while (timer2);
        }
        }

        // 毫秒延時
        void DelayMs(unsigned int number)
        {
        unsigned char temp;

        for(;number!=0;number--)
        for(temp=112;temp!=0;temp--);
        }

        /*************************************
        在定時器中斷中做LED的PWM輸出
        *************************************/
        void timers0() interrupt 1 using 1
        {
        TH0 = 0xff;
        TL0 = 0xd0;
        timer1--;
        if (timer1==pwm1)LED=0;
        if (timer1==0){
        LED=1;
        timer1=0x40;
        timer2--;
        };
        }

        比較器相關(guān)文章:比較器工作原理


        塵埃粒子計數(shù)器相關(guān)文章:塵埃粒子計數(shù)器原理
        蜂鳴器相關(guān)文章:蜂鳴器原理

        上一頁 1 2 下一頁

        關(guān)鍵詞: 語言 源程序 AD 模擬 比較

        評論


        相關(guān)推薦

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

        關(guān)閉