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

📄 tb1820.lst

📁 使用c编写的一套温控程序,可是通过外部调节来设置上限温度,和下限温度,在正常的范围内,有正常指示灯指示,当超过上限时,超上限温度指示灯指示,当低于下限时,下限温度指示灯指示,也可以通过外围电路连接其他
💻 LST
字号:
C51 COMPILER V8.02   TB1820                                                                03/13/2008 09:21:27 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE TB1820
OBJECT MODULE PLACED IN TB1820.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE TB1820.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1           /*8M crystal ,temperture detector.The number of controlling 
   2                                         device is DS1820*/
   3          #include<REGX51.h>
   4          #include<absacc.h>
   5          #include<stdio.h>
   6          #include<math.h>
   7          #include<float.h>
   8          #define uchar unsigned char
   9          #define uint unsigned int
  10          char code codenumber[]={0x03,0x9f,0x25,0x0c,0x99,0x48,0x40,0x1f,0x00,0x09};
  11          uchar termp1,termp2,set;
  12          static uchar   uptemp,downtemp,j;
  13           int  tmpt=0;
  14           void dsreset(void)        /*初始化*/
  15            {    unsigned char i;
  16   1        start: 
  17   1                i=200;
  18   1            P3_5=0;
  19   1            while(i>0) i--;
  20   1                P3_5=1;
  21   1            i=20;
  22   1            while(i>0) i--;
  23   1                while(P3_5==1) goto start;
  24   1                i=40;
  25   1                while(i>0)
  26   1                { if(P3_5==1) break;
  27   2                  i--;
  28   2                 }
  29   1                 if(i==0)  goto start;
  30   1                 else P3_5=1;
  31   1                 i=160;
  32   1                 while(i>0) i--;
  33   1        }
  34          unsigned char tmpread2(void)   /*读一字节*/
  35            {   unsigned char i, k,dat2;
  36   1            bit testb;
  37   1           dat2=0;
  38   1          for(i=0;i<8;i++)
  39   1             {  P3_5=0; 
  40   2                     k=4;
  41   2                        P3_5=1;
  42   2                        while(k>0) k--;
  43   2                        testb=P3_5;
  44   2                         k=18;
  45   2                        while(k>0) k--;
  46   2                        dat2=dat2>>1;
  47   2                       dat2=testb?dat2|0x80:dat2|0x00;
  48   2               }
  49   1              return(dat2);
  50   1              }
  51           void tmpwrite(unsigned char dat)        /*写字节数据*/
  52           {
  53   1           unsigned int i;
  54   1               unsigned char j;
  55   1               bit testb;
C51 COMPILER V8.02   TB1820                                                                03/13/2008 09:21:27 PAGE 2   

  56   1               for(j=0;j<8;j++)
  57   1               {  
  58   2                  testb=dat&0x01;
  59   2                      dat=dat>>1;
  60   2                      P3_5=0;
  61   2                      i=1;
  62   2                      while(i>0) i--;
  63   2                      P3_5=testb;
  64   2                      i=4;
  65   2                      while(i>0) i--;
  66   2                      P3_5=1;
  67   2                }
  68   1              }
  69           void tmpchange(void)    /*温度转换*/
  70            { 
  71   1              dsreset();
  72   1               tmpwrite(0xcc);
  73   1               tmpwrite(0x44);
  74   1        }
  75            void showtermp()
  76            {       
  77   1                unsigned char ten;
  78   1                        if(set==1)
  79   1                        return;
  80   1                        if(termp2&0x80) 
  81   1                         { termp1=~termp1+1;
  82   2                   termp2=~termp2;
  83   2                               if(termp1==0)
  84   2                               termp2=termp2+1;
  85   2                               termp2=termp2*16;
  86   2                               termp1=termp1&0xf0;
  87   2                               termp1=termp1>>4;
  88   2                               tmpt=termp2+termp1;
  89   2                               ten=tmpt/10;
  90   2                      P0=codenumber[ten];
  91   2                              ten=tmpt%10;
  92   2                                P2=codenumber[ten]; 
  93   2                               P3_7=0;
  94   2                          }
  95   1                              else{ termp2=termp2*16;
  96   2                               termp1=termp1&0xf0;
  97   2                               termp1=termp1>>4;
  98   2                               tmpt=termp2+termp1;
  99   2                               ten=tmpt/10;
 100   2                               P3_7=1;  
 101   2                              P0=codenumber[ten];
 102   2                               ten=tmpt%10;
 103   2                                P2=codenumber[ten];
 104   2                               
 105   2                               
 106   2                               }
 107   1      
 108   1                         }
 109                             void delay()
 110                             { unsigned char i,j;
 111   1                          for(i=0;i<250;i++)
 112   1                              for(j=0;j<254;j++);
 113   1                              }
 114            void control(void)        /*温度设置*/
 115            {      uchar i,l; 
 116   1        if(P3_2==0||set==1)
 117   1           { if(P3_2==0)
C51 COMPILER V8.02   TB1820                                                                03/13/2008 09:21:27 PAGE 3   

 118   2                { i=20; 
 119   3                  while(i--);
 120   3                  if(P3_2==0)
 121   3                 { while(P3_2==0);
 122   4                 set++;
 123   4                 if(set==2)
 124   4                  set=0; } }
 125   2                
 126   2                if(set==1)
 127   2                {  
 128   3                 if(P3_3==0)
 129   3                 {   for(i=0;i<102;i++);
 130   4                   if(P3_3==0)
 131   4                       {  while(P3_3==0);
 132   5                 uptemp++;
 133   5                 if(uptemp==85) 
 134   5                 uptemp=35;
 135   5                 P0=codenumber[uptemp/10];
 136   5                P2=codenumber[uptemp%10];
 137   5                 
 138   5                  }
 139   4                 }    
 140   3                if(P3_4==0)
 141   3                { for(i=0;i<100;i++);
 142   4                 if(P3_4==0)
 143   4               {  while(P3_4==0);
 144   5               downtemp--;
 145   5                 if(downtemp==3) 
 146   5                 downtemp=30;
 147   5                      P3_7=0;
 148   5                 
 149   5                 P0=codenumber[downtemp/10];
 150   5                 
 151   5                 
 152   5                 P2=codenumber[downtemp%10];
 153   5                 
 154   5                 P3_7=1; } 
 155   4                 } l++;
 156   3                 if(l==1)
 157   3                 {  if(l==2)
 158   4                    l=0;
 159   4                 delay();
 160   4                 delay();
 161   4                 P0=0xff;
 162   4                 P2=0xff;
 163   4                 delay();     }
 164   3                
 165   3                 }
 166   2                 }
 167   1                 }
 168            void out(void)
 169            { if(downtemp<tmpt&&tmpt<uptemp)
 170   1           P1=0x0F2;
 171   1                else if(tmpt>uptemp||tmpt==uptemp)
 172   1                 P1=0x04;
 173   1                else  P1=0x01;
 174   1                }
 175            void  main(void)
 176            {
 177   1        unsigned char i;
 178   1            SCON=0x00;
 179   1                P3_7=0;
C51 COMPILER V8.02   TB1820                                                                03/13/2008 09:21:27 PAGE 4   

 180   1                 set=0;
 181   1                uptemp=40;
 182   1                downtemp=35;
 183   1        
 184   1           do {  control();
 185   2                    P3_5=1;
 186   2                    tmpchange();
 187   2                        dsreset();
 188   2                        tmpwrite(0xcc);
 189   2                        tmpwrite(0xbe);
 190   2                   termp1=tmpread2();
 191   2               termp2=tmpread2();
 192   2                       P3_5=0;
 193   2                       i=150;
 194   2                       while(i>0) i--;
 195   2                         showtermp();
 196   2                         out();
 197   2                      }while(1);
 198   1              }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    600    ----
   CONSTANT SIZE    =     10    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      8       1
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       2
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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