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

📄 biaojue.lst

📁 2010年新增TX-1C程序
💻 LST
字号:
C51 COMPILER V8.02   BIAOJUE                                                               06/25/2010 13:35:57 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE BIAOJUE
OBJECT MODULE PLACED IN biaojue.OBJ
COMPILER INVOKED BY: D:\处理软件\keil\C51\BIN\C51.EXE biaojue.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*********************************************************************************
   2                                                          “天祥电子”            倾情奉献
   3          
   4                                                                          www.txmcu.cn
   5                                                                          www.txmcu.com
   6          
   7          **********************************************************************************
   8          
   9          程序功能:表决器,模拟三位评委的表决,并做出判断,将结果显示于1602上。
  10                            共用到TX-1C学习板上左二列的S6,S7,S10,S11,S14,S15,S18七个按键。
  11                            其中S18为清零键,对1602进行清屏和对相关变量清零。
  12                            每位评委操控两个按键,分别代表“通过”和“不通过”。
  13                            第一位评委控制S6(通过)与S7(不通过);
  14                            第二位评委控制S10(通过)与S11(不通过);
  15                            第三位评委控制S14(通过)与S15(不通过);
  16                            当按“通过”次数多于“不通过”时,1602将显示“yes”,否则显示“no”。
  17                            在一个回合中,每位评委只有一次按键的权利,一旦按下,其操控的两个
  18                            按键均将被封锁,再按也不会有任何作用。除非按下清零键S18清零后开始下一回合。
  19          
  20          ************************************************************************************/
  21          
  22          #include<reg52.h>
  23          #define uchar unsigned char 
  24          #define uint unsigned int
  25          sbit dula=P2^6;
  26          sbit wela=P2^7;
  27          sbit rs=P3^5;
  28          sbit beep=P2^3;
  29          sbit lcden=P3^4;
  30          
  31          bit ok1,ok2,ok3,clear;
  32          
  33          uchar pass,nopass,temp;
  34          uchar table[]="yes";
  35          uchar table1[]="no";
  36          uchar table2[]="agree";
  37          uchar table3[]="disagree";
  38          uchar table4[]="   ";
  39          uchar table5[]="  ";
  40          
  41          void delay(uint z)
  42          {
  43   1              uint x,y;
  44   1              for(x=z;x>0;x--)
  45   1                      for(y=110;y>0;y--);
  46   1      }
  47          
  48          
  49          
  50          void write_com(uchar com)
  51          {
  52   1              rs=0;
  53   1              lcden=0;
  54   1              P0=com;
  55   1              delay(5);
C51 COMPILER V8.02   BIAOJUE                                                               06/25/2010 13:35:57 PAGE 2   

  56   1              lcden=1;
  57   1              delay(5);
  58   1              lcden=0;        
  59   1      }
  60          
  61          void write_date(uchar date)
  62          {
  63   1              rs=1;
  64   1              lcden=0;
  65   1              P0=date;
  66   1              delay(5);
  67   1              lcden=1;
  68   1              delay(5);
  69   1              lcden=0;        
  70   1      }
  71          
  72          
  73          
  74          void init()
  75          {
  76   1      //      uchar a;
  77   1              dula=0;
  78   1              wela=0;
  79   1              write_com(0x38);
  80   1              delay(20);
  81   1              write_com(0x0c);
  82   1              delay(20);
  83   1              write_com(0x06);
  84   1              delay(20);
  85   1              write_com(0x01);
  86   1              delay(20);
  87   1                      
  88   1      }
  89          
  90          void yes()
  91          {
  92   1              uchar a;
  93   1              write_com(0x80+12);
  94   1              delay(20);
  95   1              for(a=0;a<3;a++)
  96   1              {
  97   2                      write_date(table[a]);
  98   2                      delay(20);
  99   2              }
 100   1      }
 101          
 102          void no()
 103          {
 104   1              uchar a;
 105   1              write_com(0x80+0x40+12);
 106   1              delay(20);
 107   1              for(a=0;a<2;a++)
 108   1              {
 109   2                      write_date(table1[a]);
 110   2                      delay(20);
 111   2              }
 112   1      }
 113          
 114          void agree()
 115          {
 116   1              uchar a;
 117   1              write_com(0x80);
C51 COMPILER V8.02   BIAOJUE                                                               06/25/2010 13:35:57 PAGE 3   

 118   1              delay(20);
 119   1              for(a=0;a<5;a++)
 120   1              {
 121   2                      write_date(table2[a]);
 122   2                      delay(20);
 123   2              }
 124   1      }
 125          
 126          void disagree()
 127          {
 128   1              uchar a;
 129   1              write_com(0x80+0x40);
 130   1              delay(20);
 131   1              for(a=0;a<8;a++)
 132   1              {
 133   2                      write_date(table3[a]);
 134   2                      delay(20);
 135   2              }
 136   1      }
 137          
 138          void keyscan()
 139          {
 140   1          if(!ok1)
 141   1              { 
 142   2              P3=0xfe;
 143   2          temp=P3;
 144   2          temp=temp&0xf0;
 145   2          if(temp!=0xf0)
 146   2          {
 147   3            delay(10);
 148   3            if(temp!=0xf0)
 149   3            {
 150   4              temp=P3;
 151   4                      switch(temp)
 152   4              {
 153   5                case 0xee:
 154   5                     pass++;
 155   5                                 ok1=1;               //一号评委已判决。
 156   5                     break;
 157   5      
 158   5                case 0xde:
 159   5                     nopass++;
 160   5                                 ok1=1;
 161   5                     break;
 162   5               }
 163   4               while(temp!=0xf0)
 164   4               {
 165   5                 temp=P3;
 166   5                 temp=temp&0xf0;
 167   5                 beep=0;
 168   5               }
 169   4               beep=1;
 170   4            }
 171   3          }
 172   2              }
 173   1              if(!ok2)
 174   1              {
 175   2          P3=0xfd;
 176   2          temp=P3;
 177   2          temp=temp&0xf0;
 178   2          if(temp!=0xf0)
 179   2          {
C51 COMPILER V8.02   BIAOJUE                                                               06/25/2010 13:35:57 PAGE 4   

 180   3            delay(10);
 181   3            if(temp!=0xf0)
 182   3            {
 183   4              temp=P3;
 184   4              switch(temp)
 185   4              {
 186   5                case 0xed:
 187   5                     pass++;
 188   5                                 ok2=1;
 189   5                     break;
 190   5      
 191   5                case 0xdd:
 192   5                     nopass++;
 193   5                                 ok2=1;
 194   5                     break;
 195   5               }
 196   4               while(temp!=0xf0)
 197   4               {
 198   5                 temp=P3;
 199   5                 temp=temp&0xf0;
 200   5                 beep=0;
 201   5               }
 202   4               beep=1;
 203   4            }
 204   3            }
 205   2                }
 206   1              if(!ok3)
 207   1              {
 208   2          P3=0xfb;
 209   2          temp=P3;
 210   2          temp=temp&0xf0;
 211   2          if(temp!=0xf0)
 212   2          {
 213   3            delay(10);
 214   3            if(temp!=0xf0)
 215   3            {
 216   4              temp=P3;
 217   4              switch(temp)
 218   4              {
 219   5                case 0xeb:
 220   5                     pass++;
 221   5                                 ok3=1;
 222   5                     break;
 223   5      
 224   5                case 0xdb:
 225   5                     nopass++;
 226   5                                 ok3=1;
 227   5                     break;
 228   5               }
 229   4               while(temp!=0xf0)
 230   4               {
 231   5                 temp=P3;
 232   5                 temp=temp&0xf0;
 233   5                 beep=0;
 234   5               }
 235   4               beep=1;
 236   4            }
 237   3            }
 238   2                }
 239   1                    P3=0xf7;
 240   1          temp=P3;
 241   1          temp=temp&0xf0;
C51 COMPILER V8.02   BIAOJUE                                                               06/25/2010 13:35:57 PAGE 5   

 242   1          if(temp!=0xf0)
 243   1          {
 244   2            delay(10);
 245   2            if(temp!=0xf0)
 246   2            {
 247   3              temp=P3;
 248   3              switch(temp)
 249   3              {
 250   4                case 0xe7:
 251   4                     clear=1;
 252   4                     break;
 253   4                
 254   4               }
 255   3               while(temp!=0xf0)
 256   3               {
 257   4                 temp=P3;
 258   4                 temp=temp&0xf0;
 259   4                 beep=0;
 260   4               }
 261   3               beep=1;
 262   3            }
 263   2          }
 264   1      }
 265          
 266          void main()
 267          {
 268   1              uchar a,b;
 269   1              init();
 270   1              while(1)
 271   1              {       
 272   2                      agree();
 273   2                      disagree();
 274   2                      keyscan();
 275   2                      if(pass||nopass)
 276   2                      {
 277   3                              write_com(0x80+10);
 278   3                              delay(20);
 279   3                              write_date(0x30+pass);
 280   3                              write_com(0x80+0x40+10);
 281   3                              delay(20);
 282   3                              write_date(0x30+nopass);
 283   3                      }
 284   2                      a=pass+nopass;
 285   2                      if(a==3)
 286   2                      {
 287   3                              if(pass>nopass)
 288   3                              yes();
 289   3                              if(pass<nopass)
 290   3                              no(); 
 291   3                      }
 292   2                      if(clear)
 293   2                      {
 294   3                              ok1=0;  ok2=0;  ok3=0;  
 295   3                              pass=0; nopass=0;       clear=0;        a=0;
 296   3                              agree();
 297   3                              disagree();
 298   3                              write_com(0x80+10);
 299   3                              delay(20);
 300   3                              write_date(0x30+pass);
 301   3                              write_com(0x80+0x40+10);
 302   3                              delay(20);
 303   3                              write_date(0x30+nopass);
C51 COMPILER V8.02   BIAOJUE                                                               06/25/2010 13:35:57 PAGE 6   

 304   3              
 305   3                              write_com(0x80+12);
 306   3                              for(b=0;b<3;b++)
 307   3                              {
 308   4                                      write_date(table4[b]);
 309   4                                      delay(20);
 310   4                              }
 311   3                              write_com(0x80+0x40+12);
 312   3                              for(b=0;b<2;b++)
 313   3                              {
 314   4                                      write_date(table5[b]);
 315   4                                      delay(20);
 316   4                              } 
 317   3                      }          
 318   2              }
 319   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    642    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     32    ----
   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 + -