⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ds1820.lst

📁 基于C51的通用人机界面程序
💻 LST
字号:
C51 COMPILER V7.08   DS1820                                                                01/06/2006 09:45:01 PAGE 1   


C51 COMPILER V7.08, COMPILATION OF MODULE DS1820
OBJECT MODULE PLACED IN .\output\ds1820.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ds1820.c BROWSE DEBUG OBJECTEXTEND OBJECT(.\output\ds1820.obj)

line level    source

   1          #define _buzzer_ 
   2          #include "general.h"
   3          #include "state.h"
   4          #include "delay.h"
   5          
   6          
   7          extern uchar temrom[9];
   8          
   9          //f=11.0592M,  _nop_()  1.085us
  10          //8*12/11.0592=8.68us
  11          /*void delay1(uchar i){
  12                  //while(i)i--;
  13                  for(;i>0;i--);//8*1.085
  14          }*/
  15          
  16          bit reset(void){
  17   1              uchar data temp;
  18   1          DQ=0;
  19   1          for(temp=0;temp<150;temp++);        //500us(>=480us)
  20   1          DQ=1;
  21   1          for(temp=0;temp<15;temp++);         //90us
  22   1          if(DQ){//无存在脉冲
  23   2                      Index=31;
  24   2              return(0);                                      //总线上无传感器
  25   2              }
  26   1          for(temp=0;temp<114;temp++);        //延时 500us
  27   1                      return(1);                                      //存在
  28   1              
  29   1      }
  30          //从总线上读入1位,返回总线01值
  31          bit readbit(){
  32   1          uchar data temp;
  33   1          DQ=0;//拉低总线产生时间片并保持至少1us,数据15us后到来(13.8个nop)
  34   1          _nop_ ();//1.085us
  35   1          _nop_ ();//1.085us
  36   1          _nop_ ();//1.085us
  37   1          _nop_ ();//1.085us
  38   1          DQ=1;
  39   1          _nop_ ();//1.085us
  40   1          _nop_ ();//1.085us
  41   1          _nop_ ();//1.085us
  42   1          _nop_ ();//1.085us
  43   1          _nop_ ();//1.085us
  44   1          _nop_ ();//1.085us
  45   1          _nop_ ();//1.085us
  46   1          _nop_ ();//1.085us
  47   1          _nop_ ();//1.085us-13
  48   1          if(DQ){//读到1
  49   2              for(temp=0;temp<10;temp++);//剩余延时45us
  50   2              return(1);
  51   2          }
  52   1          else{//读到0
  53   2              for(temp=0;temp<10;temp++);//剩余延时45us
  54   2              return(0);
  55   2          }
C51 COMPILER V7.08   DS1820                                                                01/06/2006 09:45:01 PAGE 2   

  56   1      }
  57          
  58          //往总线上写入0或写入1
  59          void writebit(bit wbit){
  60   1          uchar data temp;
  61   1          DQ=0;
  62   1          if(wbit){//写1
  63   2              _nop_ ();_nop_ ();_nop_ ();_nop_ ();_nop_ ();//1.085*5
  64   2              _nop_ ();_nop_ ();_nop_ ();_nop_ ();_nop_ ();
  65   2                      _nop_ ();_nop_ ();_nop_ ();_nop_ ();_nop_ ();
  66   2              //传感器将在15~60us采样       
  67   2              DQ=1;
  68   2              for(temp=0;temp<20;temp++);//60us持续期
  69   2          }
  70   1          else{//写0
  71   2              for(temp=0;temp<20;temp++);//60us持续期
  72   2              DQ=1;    
  73   2          }
  74   1      }
  75          
  76          uchar readchar(void){//读一个字节
  77   1              uchar data temp,j;
  78   1          temp=0;
  79   1          for(j=0;j<8;j++){
  80   2              temp/=2;                        //>>
  81   2              if(readbit()) temp+=0x80;
  82   2                      _nop_();
  83   2                      _nop_();
  84   2                      _nop_();
  85   2                      _nop_();//恢复时间
  86   2          }
  87   1          return(temp);
  88   1      }
  89          
  90          
  91          void writechar(uchar ch){//写一个字节
  92   1              uchar data j;
  93   1          for(j=0;j<8;j++)
  94   1          {
  95   2              if(ch&0x01)
  96   2                  writebit(1);
  97   2              else
  98   2                  writebit(0);
  99   2              ch/=2;                          //>>
 100   2          }
 101   1      
 102   1      }
 103          void readtemp(void){
 104   1              //uint tem;
 105   1          //union{    uchar c[2];     //整数
 106   1              //              int x;          //小数
 107   1              //}temp;
 108   1              reset();
 109   1              writechar(0xCC);                                //Skip ROM
 110   1              writechar(0x44);                                // Start Conversion     
 111   1              
 112   1              delay(2000);    
 113   1      
 114   1              reset();
 115   1              writechar(0xCC);                                // Skip ROM
 116   1              writechar(0xBE);                                // Read Scratch Pad
 117   1      
C51 COMPILER V7.08   DS1820                                                                01/06/2006 09:45:01 PAGE 3   

 118   1              temrom[0]=readchar();_nop_();   //lsd低8位
 119   1              temrom[1]=readchar();_nop_();   //msd高8位
 120   1              //temrom[2]=readchar();_nop_();
 121   1              //temrom[3]=readchar();_nop_();
 122   1              //temrom[4]=readchar();_nop_();
 123   1              //temrom[5]=readchar();_nop_();
 124   1              //temrom[6]=readchar();_nop_();
 125   1              //temrom[7]=readchar();_nop_();
 126   1              //temrom[8]=readchar();_nop_();
 127   1              
 128   1              //tem=temrom[1];
 129   1          //tem=tem*256;
 130   1          //tem+=temrom[0];
 131   1      
 132   1      
 133   1          /*tem=0.0;       
 134   1              if(temp.x & 0x01) tem+=0.0625;          temp.x>>=1;
 135   1              if(temp.x & 0x01) tem+=0.125;           temp.x>>=1;
 136   1              if(temp.x & 0x01) tem+=0.25;            temp.x>>=1;
 137   1              if(temp.x & 0x01) tem+=0.5;                     temp.x>>=1;
 138   1              tem+=temp.x;
 139   1              */
 140   1      
 141   1          //return tem;
 142   1      }
 143          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    205    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       1
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -