日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁(yè) > 測(cè)試測(cè)量 > 設(shè)計(jì)應(yīng)用 > 基于DS18B20與TMS320LF2407A的測(cè)溫系統(tǒng)

          基于DS18B20與TMS320LF2407A的測(cè)溫系統(tǒng)

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

          /* 從傳感器中讀一個(gè)字節(jié) */
          void read_byte(unchar *ReadByte)
          {
          int i;
          unchar temp=0;
          unint loopindex=0;
          PIN_HIGH();
          for(i=0;i8;i++)
          {
          temp=temp>>1;
          PIN_LOW();
          nop();nop();nop();nop(); /*延時(shí)2us */
          nop();nop();nop();nop();
          PIN_HIGH();
          for(loopindex=0;loopindex6;loopindex++){;} /* 延時(shí)14us */
          PIN_LEAVE();
          nop();
          if((DATA_PORT DATA_BIT) == 0x0000)
          { temp=temp 0x7F; }
          else
          { temp=temp | 0x80; }
          PIN_HIGH();
          for(loopindex=0;loopindex26;loopindex++){;} /* 延時(shí)60us */
          }
          *ReadByte=temp;
          return;
          }
          /* 將讀得的溫度轉(zhuǎn)化為十進(jìn)制 */
          float transform(unchar *T)
          {
          unchar temp=0;
          float temprature=0;
          temp=temp|(*(T+1)8);
          temp=temp|*T;
          if((temp0x0F800)==0x0F800)
          { temprature=0-((~temp)+1)*0.0625; }
          else
          { temprature=temp*0.0625; }
          return(temprature);
          }
          /* 讀取溫度主函數(shù),返回十進(jìn)制溫度數(shù) */
          float read_temp()
          {
          Unchar buff[2];
          float temprature=0;
          unint loopindex=0;
          while (reset()==1){}; /* 復(fù)位等待從機(jī)應(yīng)答 */
          write_byte(0xCC); /* 忽略ROM匹配 */
          write_byte(0x44); /* 發(fā)送溫度轉(zhuǎn)化命令 */
          for(loopindex=0;loopindex65535;loopindex++){;} /* 延時(shí)300ms,等待數(shù)模轉(zhuǎn)換 */
          for(loopindex=0;loopindex65535;loopindex++){;}
          while(reset()==1){}; /* 再次復(fù)位,等待從機(jī)應(yīng)答 */
          write_byte(0xCC); /* 忽略ROM匹配 */
          write_byte(0xBE); /* 發(fā)送讀溫度命令 */
          read_byte(buff); /* 讀出溫度低8位 */
          read_byte(buff+1); /* 讀出溫度高8位 */
          temprature=transform(buff);
          PIN_HIGH(); /* 釋放總線 */
          return(temprature);
          }

          本文引用地址:http://yuyingmama.com.cn/article/195524.htm

            4 結(jié)束語(yǔ)

            DS20是一款非常優(yōu)秀的單總線數(shù)字式傳感器。硬件設(shè)計(jì)簡(jiǎn)單,運(yùn)行可靠。通過(guò)分析C語(yǔ)言編譯后的匯編語(yǔ)言可以很明確的計(jì)算出軟件延時(shí)的時(shí)間,從而滿足單線總線通訊的時(shí)序要求,從而可以出色的完成DSP與DS20通訊的軟件設(shè)計(jì)。

            5 本文創(chuàng)新點(diǎn)有兩個(gè):

            1、通過(guò)C編譯器編譯出來(lái)的相應(yīng)的C語(yǔ)言的延時(shí)程序,從而得到其對(duì)應(yīng)的匯編語(yǔ)言,再通過(guò)定時(shí)器計(jì)時(shí),能夠知道單指令周期的時(shí)間,從而能夠精確的計(jì)算出軟件延時(shí)程序的延時(shí)時(shí)間。

            2、通常DS20都是與單片機(jī)配合使用的,而本文則詳細(xì)的介紹了DS18與DSP的結(jié)合使用方法,其區(qū)別主要是在端口的操作上和延時(shí)的控制上。


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

          關(guān)鍵詞: 2407A 2407 18B B20

          評(píng)論


          相關(guān)推薦

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

          關(guān)閉