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

📄 a.lst

📁 key-led 矩阵键盘输入号码 数码管显示(6位)
💻 LST
字号:
C51 COMPILER V8.08   A                                                                     10/19/2008 21:52:11 PAGE 1   


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

line level    source

   1          #include<reg52.h>
   2          
   3          #define uchar unsigned char
   4          #define uint unsigned int
   5          
   6          sbit dula=P2^6;
   7          sbit wela=P2^7;
   8          
   9          uchar code table[]={
  10          0x3f,0x06,0x5b,0x4f,
  11          0x66,0x6d,0x7d,0x07,
  12          0x7f,0x6f,0x77,0x7c,
  13          0x39,0x5e,0x79,0x71,0};
  14          uchar code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
  15          
  16          uchar num,temp;  uchar key;
  17          uchar count=0;
  18          uchar data lednum[6]={17,17,17,17,17,17};
  19          
  20          void delay(uint z)
  21          {
  22   1              uint x,y;
  23   1              for(x=z;x>0;x--)
  24   1                      for(y=110;y>0;y--);
  25   1      }
  26          void display(uchar data* a);
  27          uchar keyscan();
  28          
  29          
  30          void main()
  31          {
  32   1              while(1)
  33   1              {
  34   2                      key=keyscan();
  35   2                      if(key!=17)
  36   2                      {
  37   3                              if(count==6)count=0;
  38   3                              lednum[count]=key;      
  39   3                              count++;                
  40   3                      }
  41   2      
  42   2                      display(lednum);
  43   2      
  44   2              }
  45   1      
  46   1                      
  47   1      }
  48          
  49          void display(uchar data* a)
  50          {
  51   1              uchar i;
  52   1              for(i=0;i<6;i++)
  53   1              {
  54   2                      dula=1;
  55   2                      P0=table[a[i]-1];
C51 COMPILER V8.08   A                                                                     10/19/2008 21:52:11 PAGE 2   

  56   2                      dula=0;
  57   2                      P0=0xff;
  58   2                      wela=1;
  59   2                      P0=tab[i];
  60   2                      wela=0;
  61   2                      delay(1);
  62   2              }
  63   1      
  64   1              
  65   1                              
  66   1      }
  67          
  68          
  69          uchar keyscan()
  70          {
  71   1                              num=17;
  72   1                              P3=0xfe;
  73   1                              temp=P3;
  74   1                              temp=temp&0xf0;
  75   1                              while(temp!=0xf0)
  76   1                                      {
  77   2                                              delay(5);
  78   2                                              temp=P3;
  79   2                                              temp=temp&0xf0;
  80   2                                              while(temp!=0xf0)
  81   2                                              {
  82   3                                                      temp=P3;
  83   3                                              switch(temp)
  84   3                                                      {
  85   4                                                              case 0xee:num=2;
  86   4                                                                      break;
  87   4                                                              case 0xde:num=3;
  88   4                                                                      break;
  89   4                                                              case 0xbe:num=4;
  90   4                                                                      break;
  91   4                                                              case 0x7e:num=1;
  92   4                                                                      break;
  93   4                                                      }
  94   3                                              while(temp!=0xf0)
  95   3                                                      {
  96   4                                                              temp=P3;
  97   4                                                              temp=temp&0xf0;
  98   4                                                      }
  99   3                                              }
 100   2                                      }
 101   1      
 102   1                              P3=0xfd;
 103   1                              temp=P3;
 104   1                              temp=temp&0xf0;
 105   1                              while(temp!=0xf0)
 106   1                                      {
 107   2                                              delay(5);
 108   2                                              temp=P3;
 109   2                                              temp=temp&0xf0;
 110   2                                              while(temp!=0xf0)
 111   2                                              {
 112   3                                                      temp=P3;
 113   3                                              switch(temp)
 114   3                                                      {
 115   4                                                              case 0xed:num=5;
 116   4                                                                      break;
 117   4                                                              case 0xdd:num=6;
C51 COMPILER V8.08   A                                                                     10/19/2008 21:52:11 PAGE 3   

 118   4                                                                      break;
 119   4                                                              case 0xbd:num=7;
 120   4                                                                      break;
 121   4                                                              //case 0x7d:flag1=1;
 122   4                                                              //      break;
 123   4                                                      }
 124   3                                              while(temp!=0xf0)
 125   3                                                      {
 126   4                                                              temp=P3;
 127   4                                                              temp=temp&0xf0;
 128   4                                                      }
 129   3                                              }
 130   2                                      }
 131   1      
 132   1      
 133   1                              P3=0xfb;
 134   1                              temp=P3;
 135   1                              temp=temp&0xf0;
 136   1                              while(temp!=0xf0)
 137   1                                      {
 138   2                                              delay(5);
 139   2                                              temp=P3;
 140   2                                              temp=temp&0xf0;
 141   2                                              while(temp!=0xf0)
 142   2                                              {
 143   3                                                      temp=P3;
 144   3                                              switch(temp)
 145   3                                                      {
 146   4                                                              case 0xeb:num=8;
 147   4                                                                      break;
 148   4                                                              case 0xdb:num=9;
 149   4                                                                      break;
 150   4                                                              case 0xbb:num=10;
 151   4                                                                      break;
 152   4                                                      //      case 0x7b:flag2=1;
 153   4                                                              //      break;
 154   4                                                      }
 155   3                                              while(temp!=0xf0)
 156   3                                                      {
 157   4                                                              temp=P3;
 158   4                                                              temp=temp&0xf0;
 159   4                                                      }
 160   3                                              }
 161   2                                      }
 162   1      
 163   1      return num;
 164   1      
 165   1      }
 166          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    350    ----
   CONSTANT SIZE    =     23    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     10    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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