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

📄 key.lst

📁 4×4按键扫描
💻 LST
字号:
C51 COMPILER V8.02   KEY                                                                   10/08/2008 17:00:28 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE KEY
OBJECT MODULE PLACED IN key.OBJ
COMPILER INVOKED BY: D:\keil 8.02\C51\BIN\C51.EXE key.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include<reg52.h>
   2          #include<intrins.h>
   3          #include"Key.h"
   4          #include"lcd.h"
   5          
   6          /***************************************************************
   7          *                                                       BeepMs
   8          ***************************************************************/
   9          void BeepMs(unsigned long int beep_time)
  10          {
  11   1              Beep = 0;
  12   1          DelayMs(beep_time);                                 // 改变时间参数可改变声音 
  13   1              Beep = 1;
  14   1      }
  15          
  16          /***************************************************************
  17          *                                                       Send a byte
  18          ***************************************************************/
  19          /*void SendByte(unsigned char ch) 
  20          {
  21                  SBUF = ch;               
  22                  while(!TI)
  23                  {
  24                          //_CLRWDT_;
  25                          ;
  26                  } 
  27                  TI = 0;
  28                  
  29          }*/
  30          
  31          /***************************************************************
  32          *                                                 KeyScan
  33          ***************************************************************/
  34          unsigned char KeyScan()
  35          {
  36   1              Key7 = 0;       Key6 = 1;       Key5 = 1;       Key4 = 1;               //扫描第一行
  37   1              if (!Key0)
  38   1              {
  39   2                      DelayMs(10);
  40   2                      if (!Key0)
  41   2                      {
  42   3                              BeepMs(1);
  43   3                              WriteDataLcd(ValKey1+48);
  44   3                              return (ValKey1);
  45   3                      }
  46   2              }
  47   1              else if (!Key1)
  48   1              {
  49   2                      DelayMs(10);
  50   2                      if (!Key1)
  51   2                      {
  52   3                              BeepMs(1);
  53   3                              WriteDataLcd(ValKey2+48);
  54   3                              return (ValKey2);
  55   3      
C51 COMPILER V8.02   KEY                                                                   10/08/2008 17:00:28 PAGE 2   

  56   3                      }
  57   2              }
  58   1              else if (!Key2)
  59   1              {
  60   2                      DelayMs(10);
  61   2                      if (!Key2)
  62   2                      {
  63   3                              BeepMs(1);
  64   3                              WriteDataLcd(ValKey3+48);
  65   3                              return (ValKey3);
  66   3                      }
  67   2              }
  68   1              else if (!Key3)
  69   1              {
  70   2                      DelayMs(10);
  71   2                      if (!Key3)
  72   2                      {
  73   3                              BeepMs(5);
  74   3                              WriteCmdLcd(0x01,1);            // 显示清屏
  75   3                              return (ValKey4);
  76   3                      }
  77   2              }
  78   1      
  79   1              Key7 = 1;       Key6 = 0;       Key5 = 1;       Key4 = 1;               //扫描第二行
  80   1              if (!Key0)
  81   1              {
  82   2                      DelayMs(10);
  83   2                      if (!Key0)
  84   2                      {
  85   3                              BeepMs(1);
  86   3                              WriteDataLcd(ValKey5+48);
  87   3                              return (ValKey5);
  88   3                      }
  89   2              }
  90   1              else if (!Key1)
  91   1              {
  92   2                      DelayMs(10);
  93   2                      if (!Key1)
  94   2                      {
  95   3                              BeepMs(1);
  96   3                              WriteDataLcd(ValKey6+48);
  97   3                              return (ValKey6);
  98   3                      }
  99   2              }
 100   1              else if (!Key2)
 101   1              {
 102   2                      DelayMs(10);
 103   2                      if (!Key2)
 104   2                      {
 105   3                              BeepMs(1);
 106   3                              WriteDataLcd(ValKey7+48);
 107   3                              return (ValKey7);
 108   3                      }
 109   2              }
 110   1              else if (!Key3)
 111   1              {
 112   2                      DelayMs(10);
 113   2                      if (!Key3)
 114   2                      {
 115   3                              BeepMs(8);
 116   3                              return (ValKey8);
 117   3                      }
C51 COMPILER V8.02   KEY                                                                   10/08/2008 17:00:28 PAGE 3   

 118   2              }
 119   1      
 120   1              Key7 = 1;       Key6 = 1;       Key5 = 0;       Key4 = 1;               //扫描第三行
 121   1              if (!Key0)
 122   1              {
 123   2                      DelayMs(10);
 124   2                      if (!Key0)
 125   2                      {
 126   3                              BeepMs(1);
 127   3                              WriteDataLcd(ValKey9+48);
 128   3                              return (ValKey9);
 129   3                      }
 130   2              }
 131   1              else if (!Key1)
 132   1              {
 133   2                      DelayMs(10);
 134   2                      if (!Key1)
 135   2                      {
 136   3                              BeepMs(1);
 137   3                              WriteDataLcd(ValKey10+48);
 138   3                              return (ValKey10);
 139   3                      }
 140   2              }
 141   1              else if (!Key2)
 142   1              {
 143   2                      DelayMs(10);
 144   2                      if (!Key2)
 145   2                      {
 146   3                              BeepMs(1);
 147   3                              WriteDataLcd(ValKey11+48);
 148   3                              return (ValKey11);
 149   3                      }
 150   2              }
 151   1              else if (!Key3)
 152   1              {
 153   2                      DelayMs(10);
 154   2                      if (!Key3)
 155   2                      {
 156   3                              BeepMs(10);
 157   3                              WriteCmdLcd(0xc0,1);            // 下一行(回车)
 158   3                              return (ValKey12);
 159   3                      }
 160   2              }
 161   1      
 162   1              Key7 = 1;       Key6 = 1;       Key5 = 1;       Key4 = 0;               //扫描第四行
 163   1              if (!Key0)
 164   1              {
 165   2                      DelayMs(10);
 166   2                      if (!Key0)
 167   2                      {
 168   3                              BeepMs(1);
 169   3                              WriteDataLcd(ValKey13+48);
 170   3                              return (ValKey13);
 171   3                      }
 172   2              }
 173   1              else if (!Key1)
 174   1              {
 175   2                      DelayMs(10);
 176   2                      if (!Key1)
 177   2                      {
 178   3                              BeepMs(1);
 179   3                              WriteDataLcd(ValKey14+48);
C51 COMPILER V8.02   KEY                                                                   10/08/2008 17:00:28 PAGE 4   

 180   3                              return (ValKey14);
 181   3                      }
 182   2              }
 183   1              else if (!Key2)
 184   1              {
 185   2                      DelayMs(10);
 186   2                      if (!Key2)
 187   2                      {
 188   3                              BeepMs(1);
 189   3                              WriteDataLcd(ValKey15+48);
 190   3                              return (ValKey15);
 191   3                      }
 192   2              }
 193   1              else if (!Key3)
 194   1              {
 195   2                      DelayMs(10);
 196   2                      if (!Key3)
 197   2                      {
 198   3                              BeepMs(15);
 199   3                              WriteDataLcd(ValKey16+48);
 200   3                              return (ValKey16);
 201   3                      }
 202   2              }
 203   1              return ValNull;
 204   1      }
 205          
 206          
 207          
 208          void Init()
 209          {
 210   1              /*TMOD = 0x21;          // T1 方式2     
 211   1              PCON = 0x00;            // PD=PCON.2 PD=1 进入掉电模式
 212   1              TH1 = TL1 = 0xFD;   // BAUD: 9600
 213   1              SCON = 0x50;            // 串行通信方式1 REN=1 允许接收
 214   1              TR1 = 1;                        // 开启定时器1
 215   1              IE = 0;                         // 关闭所有中断允许位*/
 216   1              P2 = 0xff;
 217   1      
 218   1              LcdInit();
 219   1      
 220   1              DisplayListChar(1, 1, Name);
 221   1              DisplayListChar(2, 0, Logo);
 222   1      }
 223          
 224          
 225          void main()
 226          {
 227   1              Init();
 228   1              while(1)
 229   1              {
 230   2                      KeyScan();
 231   2                      DelayMs(150);
 232   2              }                               
 233   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    497    ----
   CONSTANT SIZE    =     28    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       4
C51 COMPILER V8.02   KEY                                                                   10/08/2008 17:00:28 PAGE 5   

   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 + -