新聞中心

        EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > DS18B20數(shù)字溫度計(jì)單片機(jī)接口應(yīng)用

        DS18B20數(shù)字溫度計(jì)單片機(jī)接口應(yīng)用

        作者: 時(shí)間:2013-04-02 來(lái)源:網(wǎng)絡(luò) 收藏

        return(temp);

        }

        void main(void)

        {

        TMOD=0x01;

        TH0=(65536-4000)/256;

        TL0=(65536-4000)%6;

        ET0=1;

        EA=1;

        while(resetpulse());

        writecommandtods18b20(0xcc);

        writecommandtods18b20(0x44);

        TR0=1;

        while(1)

        {

        ;

        }

        }

        void t0(void) interrupt 1 using 0

        {

        unsigned char x;

        unsigned int result;

        TH0=(65536-4000)/256;

        TL0=(65536-4000)%6;

        if(displaycount==2)

        {

        P0=displaycode[displaybuf[displaycount]] | 0x80;

        }

        else

        {

        P0=displaycode[displaybuf[displaycount]];

        }

        P2=displaybit[displaycount];

        displaycount++;

        if(displaycount==8)

        {

        displaycount=0;

        }

        timecount++;

        if(timecount==150)

        {

        timecount=0;

        while(resetpulse());

        writecommandtods18b20(0xcc);

        writecommandtods18b20(0xbe);

        readdata[0]=readdatafromds18b20();

        readdata[1]=readdatafromds18b20();

        for(x=0;x8;x++)

        {

        displaybuf[x]=16;

        }

        sflag=0;

        if((readdata[1] 0xf8)!=0x00)

        {

        sflag=1;

        readdata[1]=~readdata[1];

        readdata[0]=~readdata[0];

        result=readdata[0]+1;

        readdata[0]=result;

        if(result>255)

        {

        readdata[1]++;

        }

        }

        readdata[1]=readdata[1]4;

        readdata[1]=readdata[1] 0x70;

        x=readdata[0];

        x=x>>4;

        x=x 0x0f;

        readdata[1]=readdata[1] | x;

        x=2;

        result=readdata[1];

        while(result/10)

        {

        displaybuf[x]=result;

        result=result/10;

        x++;

        }

        displaybuf[x]=result;

        if(sflag==1)

        {

        displaybuf[x+1]=17;

        }

        x=readdata[0] 0x0f;

        x=x1;

        displaybuf[0]=(dotcode[x]);

        displaybuf[1]=(dotcode[x])/10;

        while(resetpulse());

        writecommandtods18b20(0xcc);

        writecommandtods18b20(0x44);

        }

        }


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

        評(píng)論


        相關(guān)推薦

        技術(shù)專(zhuān)區(qū)

        關(guān)閉
        主站蜘蛛池模板: 汉阴县| 台江县| 德清县| 准格尔旗| 朝阳区| 建昌县| 伊金霍洛旗| 阳原县| 盐城市| 东丽区| 剑阁县| 甘南县| 托克逊县| 武清区| 肥城市| 依兰县| 县级市| 灌南县| 凤庆县| 衡水市| 阳春市| 手游| 铁岭县| 广丰县| 新津县| 噶尔县| 黔西| 无极县| 崇明县| 怀宁县| 全椒县| 德化县| 东兰县| 三门峡市| 荔波县| 张家界市| 宁都县| 朝阳县| 丹寨县| 龙南县| 呼伦贝尔市|