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

📄 main.lst

📁 自动生升旗系统程序
💻 LST
字号:
C51 COMPILER V7.06   MAIN                                                                  05/29/2008 16:54:28 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          
   2          
   3          
   4          #include<at89x52.h>
   5          
   6          sfr PortCode = 0x80;  // P0
   7          sfr PortBit  = 0xa0;  // P2
   8          
   9          
  10          #include <AT89X52.H>
  11          
  12          extern void ee_write(unsigned int addr, unsigned char outdat);
  13          extern unsigned char ee_read(unsigned int addr);
  14          
  15          unsigned char zhengz[]={0xf1,0xf3,0xf2,0xf6,0xf4,0xfc,0xf8,0xf9};               // ** 正转
  16          unsigned char fanz[]  ={0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0xf1};               // ** 反转 
  17          
  18          bit             run;                    // ** 开启
  19          bit             dir;                    // ** 方向
  20          unsigned int speed;             // ** 速度 
  21          unsigned char tmp ;
  22          unsigned int hight;             
  23          unsigned char DispHight;
  24          unsigned char SecCnt;
  25          unsigned char Sec;
  26          
  27          unsigned char code displaybit[9] = {
  28          0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff};       //数码管位分布(自左至右)
  29          
  30          unsigned char code displaycode[] = {
  31          0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6};  //数码管字段0,1,2,3,4,5,6,7,8,9 
  32          
  33          void delay(unsigned int Ms)
  34          {
  35   1              unsigned char i;
  36   1              
  37   1              for( ; Ms != 0; Ms-- )
  38   1              {
  39   2                      for(i = 1; i != 0; i-- );       
  40   2              }
  41   1      }
  42          
  43          void Display(unsigned long dat)
  44          {
  45   1              unsigned char i;
  46   1      
  47   1              for(i = 0; i != 8; i++)
  48   1              {       
  49   2                      PortBit = 0xFF;    //消除重影
  50   2      
  51   2                      PortCode = displaycode[dat%10];
  52   2      
  53   2                      if (i==3||i==4) PortCode = 0x2;
  54   2      
  55   2                      PortBit = displaybit[i];
C51 COMPILER V7.06   MAIN                                                                  05/29/2008 16:54:28 PAGE 2   

  56   2                      dat /= 10;
  57   2                      delay(255);     
  58   2              }
  59   1      }
  60          
  61          void initTimer(void)
  62          {
  63   1              TMOD=0x11;
  64   1              TH0=0xff;
  65   1              TL0=0xff;
  66   1              TH1=0xff;
  67   1              TL1=0xff;
  68   1      }
  69          
  70          sbit half = P1^6;
  71          bit changedir;
  72          bit UpAndDown;
  73          
  74          unsigned char cnt;
  75          unsigned char time;
  76          
  77          unsigned int  Cnt1Sec;
  78          unsigned int  TimCnt;
  79          unsigned char Current_Time;
  80          
  81          main()
  82          {
  83   1              initTimer();
  84   1              TR0=1;
  85   1              ET0=1;
  86   1              ET1=1;
  87   1              run = 0;
  88   1              tmp = 0;
  89   1              dir = 0;
  90   1              EA=1;   
  91   1              hight = ee_read(9)*60.6667+1;
  92   1              half = 1;
  93   1              time = 43;      
  94   1              Cnt1Sec = 10010/time;
  95   1              speed = 65535-101.01*time;      
  96   1              P3_7=1;
  97   1              while(1)
  98   1              {
  99   2                      if (hight!=10010 && P3_0==0)
 100   2                      {
 101   3                              delay(100);
 102   3                              if (P3_0==0)    // ** 上升
 103   3                              {
 104   4                                      
 105   4                                      run = 1;        
 106   4                                      UpAndDown = 1;
 107   4                                      changedir = 0;
 108   4                                      if(time==43&&P3_0==0)
 109   4                                      P3_7 = 0;
 110   4      
 111   4                              }
 112   3                      }
 113   2                      else if (hight!=0&&P3_1==0)
 114   2                      {
 115   3                              delay(100);
 116   3                              if (P3_1==0)    // ** 下降
 117   3                              {
C51 COMPILER V7.06   MAIN                                                                  05/29/2008 16:54:28 PAGE 3   

 118   4                                      run = 1;
 119   4                                      UpAndDown = 0;
 120   4                                      changedir = 0;
 121   4                              }
 122   3                      }
 123   2                      else if (P3_2==0)
 124   2                      {
 125   3                              delay(100);
 126   3                              if (P3_2==0)    // ** 停止
 127   3                              {
 128   4                                      EA = 0;
 129   4                                      run = 0;                                
 130   4                                      ee_write(9,hight/60.6667);
 131   4                                      EA = 1;
 132   4                                      Sec = 0;
 133   4                              }
 134   3                      }
 135   2      
 136   2                      if (P3_3==0)
 137   2                      {
 138   3                              delay(2);
 139   3                              cnt++;
 140   3                              if (P3_3==0 &&cnt==4)
 141   3                              {
 142   4                                      cnt = 0;
 143   4                                      if (time<120)time++;
 144   4                                      speed = 65535-101.01*time;  //40s走9900步,1毫秒走40000/9900=101.01
 145   4                                      Cnt1Sec = 10010/time;
 146   4                              }
 147   3                      }
 148   2                      if(P3_4==0)
 149   2                      {
 150   3                              delay(2);
 151   3                              cnt++;  
 152   3                              if (P3_4==0&&cnt==4)
 153   3                              {
 154   4                                      cnt = 0;
 155   4                                      if (time>30)time--;
 156   4                                      speed = 65535-101.01*time;  
 157   4                                      Cnt1Sec = 10010/time;
 158   4                              }
 159   3                      }
 160   2      
 161   2                      if (!half && (!run))    // ** 显示速度--当前高度
 162   2                              Display(time*100000+hight/60.6667+15);
 163   2                      else                            // ** 显示时间--当前高度
 164   2                              Display(Current_Time*100000+hight/60.6667+15);    //  10010/165=60.6667
 165   2                      
 166   2              }
 167   1      }
 168          void timer0(void) interrupt 1
 169          {
 170   1              TH0=speed/256;
 171   1              TL0=speed%256;          
 172   1      
 173   1              if (run)
 174   1              {
 175   2                      TimCnt++;
 176   2                      if (TimCnt==Cnt1Sec){Current_Time++;TimCnt=0;}            //时间显示:Cnt1Set1s走那么多步,10010/time
 177   2      
 178   2                      if(!half)                       // ** 半旗
 179   2                      {
C51 COMPILER V7.06   MAIN                                                                  05/29/2008 16:54:28 PAGE 4   

 180   3                              if (UpAndDown)  // ** 上升
 181   3                              {
 182   4                                      if(changedir==0)
 183   4                                      {
 184   5                                      hight++;
 185   5                                      dir = 1;
 186   5                                      if(changedir==0&&time==43) 
 187   5                                      P3_7=0;
 188   5                                      }
 189   4                                      else {hight--;dir = 0;P3_7=1;}
 190   4      
 191   4                                      if (changedir && hight == 6370) // ** 降到120cm
 192   4                                      {
 193   5                                              run = 0;                // ** 停止                                              
 194   5                                              ee_write(9,hight/60.6667);
 195   5                                      }
 196   4      
 197   4                                      if (hight==10010)       // ** 到达顶端
 198   4                                      {
 199   5                                              changedir = 1;                                  
 200   5                                      }
 201   4                              }
 202   3                              else            // ** 下降
 203   3                              {
 204   4                                      if(changedir==0){hight++;dir = 1;P3_7=1;}
 205   4                                      else {hight--;dir = 0;}
 206   4                                      if (hight==10010)       // ** 到达顶端  
 207   4                                      {
 208   5                                              changedir = 1;                                                                          
 209   5                                      }
 210   4                                      if (changedir && hight == 0)    // ** 降到120cm
 211   4                                      {
 212   5                                              Current_Time=0;
 213   5                                              run = 0;                // ** 停止      
 214   5                                              ee_write(9,hight/60.6667);      
 215   5                                      }
 216   4                              }
 217   3                      }
 218   2                      else
 219   2                      {
 220   3                              if (UpAndDown)  // ** 上升
 221   3                              {
 222   4                                      hight++;
 223   4                                      dir = 1;
 224   4                                      if (hight==10010)       // ** 到达顶端
 225   4                                      {
 226   5                                              run = 0;                // ** 停止      
 227   5                                              ee_write(9,hight/60.6667);
 228   5                                              P3_7 = 1;
 229   5                                      }
 230   4                              }
 231   3                              else            // ** 下降
 232   3                              {
 233   4                                      hight--;
 234   4                                      dir = 0;
 235   4                                      if (hight==0)   // ** 到达顶端
 236   4                                      {
 237   5                                              run = 0;                // ** 停止      
 238   5                                              ee_write(9,hight/60.6667);
 239   5                                      }
 240   4                              }
 241   3                  }
C51 COMPILER V7.06   MAIN                                                                  05/29/2008 16:54:28 PAGE 5   

 242   2                      if (P3_5==0&&UpAndDown){ee_write(9,hight/60.6667);run = 0;}
 243   2                      if (P3_6==0&&(!UpAndDown)){run=0;hight=0;Current_Time=0;ee_write(9,hight/60.6667);}
 244   2              }
 245   1              if (!run) P1 = 0xFF;
 246   1              else
 247   1              {
 248   2                      if (dir)
 249   2                      P1 = zhengz[tmp];       
 250   2                      else
 251   2                      P1 = fanz[tmp];         
 252   2                      tmp ++ ;
 253   2                      if (tmp>=8)tmp = 0;
 254   2              }       
 255   1      }
 256          
 257          
 258          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1190    ----
   CONSTANT SIZE    =     19    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     31       5
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      4    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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