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

📄 menjing.lst

📁 门禁系统源码。实现只识别一个或几个号码!
💻 LST
字号:
C51 COMPILER V7.07   MENJING                                                               07/04/2007 23:00:10 PAGE 1   


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

stmt level    source

   1          //#include <AT89X52.h>
   2          #include "STC12C2052.h"
   3          #include <intrins.h>
   4          
   5          
   6          #define SDA P1_0
   7          #define SCL P3_7
   8          #define uchar unsigned char
   9          #define uint unsigned int
  10          #define green_led P1_1
  11          #define open_door P1_3
  12          #define sda_mokuai P1_5
  13          #define scl_mokuai P3_3
  14          #define WAITFORKEYBOARDPULSE  while(!scl_mokuai); while(scl_mokuai)
  15          
  16          //uchar code ID_code[15]={0x7C,0x1C,0x00,0x00,0x00,0x60,0x1C,0x60,0x1C,0x80,0x60,0x60,0x1C,};
  17          //7C 1C 00 00 00 60 9C 60 1C 80 60 60 1C 
  18          //7C 1C 00 00 00 60 1C 60 1C 80 60 60 1C 
  19          //AB 30 44 30 30 34 41 41 35 31 35 46 37 0D 0A 54
  20          //AB 30 44 30 30 34 41 41 35 31 35 46 37 0D 0A 54 
  21          //AB 30 44 30 30 34 41 41 35 31 35 46 37 0D 0A 54 
  22          //30 44 30 30 34 41 41 35 31 35 46 37 0D 0A 0F AB 
  23          uchar code ID_code[16]={0xAB,0x30,0x44,0x30,0x30,0x34,0x41,0x41,0x35,0x31,0x35,0x46,0x37,0x0D,0x0A,0x54,};
             - 
  24          //AB 30 44 30 30 34 41 41 35 31 35 46 37 0D 0A 54 
  25          //uchar code ID_code[16]={0x30,0x44,0x30,0x30,0x34,0x41,0x41,0x35,0x31,0x35,0x46,0x37,0x0D,0x0A,0x0F,0xAB 
             -}; 
  26          //char code ID_code[16]={0x30,0x44,0x0f,0x30,0x34,0x41,0x41,0x35,0x31,0x35,0x46,0x37,0x0D,0x0A,0x54,0xAB }
             -; 
  27          //30 44 0F 30 34 41 41 35 31 35 46 37 0D 0A 54 AB
  28          //30 44 30 30 34 41 0F 35 31 35 46 37 0D 0A 54 AB 
  29          //30 44 0F 30 34 41 41 35 31 35 46 37 0D 0A 54 AB 
  30           uchar receive_buf[16]=0x00;
  31          
  32          //78 38 00 00 00 40 18 40 38 00 40 40 38 
  33          
  34          uchar count=0x00;//pass_flag=0x00;
  35          /*
  36          void Delay_52us_NOP(void)
  37          {
  38                  _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  39                  _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  40                  _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  41                  _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  42                  _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  43          }
  44          
  45          void Delay_26us_NOP(void)
  46          {
  47                  _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  48                  _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
  49                  _nop_();_nop_();_nop_();
  50          }
  51          */
  52          void iniMCU(void)
C51 COMPILER V7.07   MENJING                                                               07/04/2007 23:00:10 PAGE 2   

  53          {
  54   1      P1M1=0x08;
  55   1      open_door=0;
  56   1      //green_led=0;
  57   1      P0=0xff;
  58   1      //SMOD=1;
  59   1      //green_led=0;
  60   1      TMOD=0x22; // 定时器1 工作于方式2
  61   1      //20
  62   1      SCON=0x40; // 串口工作于方式1
  63   1      TH1=0xfa; //装入初值,11.0592MHZ 的晶振,9600 的波特率
  64   1      TL1=0xfa;
  65   1      PCON=0x00; //波特率无倍增
  66   1      TR1=1; //开启定时器1 开始工作
  67   1      //TR0=1; //开启定时器0 开始工作
  68   1      EA=1;
  69   1      REN=1;
  70   1      //WDT_CONTR = 0x3f;   //开硬件狗
  71   1      ES=1;   
  72   1      
  73   1          //  IT0 = 0;      //低电平引起中断
  74   1      
  75   1              ES = 1;       //开串口中断
  76   1             // EX0 = 1;      //开外部0中断
  77   1              
  78   1      }
  79                  
  80          /*********************************************************/
  81          //函数:uart
  82          //功能:串口中断
  83          //输入:无
  84          //输出:无
  85          //描述:
  86          /*********************************************************/
  87          void uart() interrupt 4 using 2
  88          {
  89   1      //ES=0;
  90   1      if(RI == 1)       //接收中断
  91   1      {
  92   2       
  93   2      receive_buf[count]=SBUF;
  94   2      
  95   2      SBUF=receive_buf[count];
  96   2      count++;
  97   2        if(SBUF==0x54){count=0x00;}//
  98   2        //pass_not();
  99   2      RI= 0;
 100   2      }
 101   1      else if(TI == 1)  //发送中断
 102   1      {
 103   2       
 104   2        TI = 0;
 105   2        //SBUF=0x77;
 106   2       // Delay_52us_NOP();
 107   2      }
 108   1      //ES=1;
 109   1      }
 110          void delay (uint us)   //delay time 
 111          { 
 112   1        while(us--); 
 113   1      } 
 114          void delay1 (uint ms) 
C51 COMPILER V7.07   MENJING                                                               07/04/2007 23:00:10 PAGE 3   

 115          { 
 116   1        uint i,j; 
 117   1        for(i=0;i<ms;i++) 
 118   1        for(j=0;j<15;j++) 
 119   1        delay(1); 
 120   1      } 
 121          
 122          void pass_not(void)
 123          {
 124   1      uchar temp=0x00,pass_flag=0x00;
 125   1      
 126   1      for(temp=0x00;temp<16;temp++)
 127   1      {               
 128   2              
 129   2              if(receive_buf[temp]==ID_code[temp])
 130   2                      {  
 131   3                              pass_flag++;
 132   3                              if(pass_flag==15)
 133   3                              {
 134   4                                      open_door=1;
 135   4                                      green_led=0;
 136   4                                      
 137   4                                      delay1(8000);
 138   4                                      delay1(8000);
 139   4                                      for(pass_flag=0x00;pass_flag<16;pass_flag++)
 140   4                                      {
 141   5                                      receive_buf[pass_flag]=0x00;    
 142   5                                      }
 143   4                                      pass_flag=0x00;
 144   4                                      open_door=0;
 145   4                                      green_led=0xff;
 146   4                              }
 147   3                      }
 148   2      
 149   2      }
 150   1      }
 151          
 152          /*
 153          void ex1() interrupt 2 using 3
 154          {        //时钟线变低
 155              unsigned char bitCount;
 156                   unsigned char KeyCode = 0;
 157                 //  if(KeyCodeSum < MAXBUFFER) KeyCodeBuff[KeyCodeSum] = 0;
 158                    // WAITFORKEYBOARDPULSE; 
 159          while(scl_mokuai);
 160          Delay_52us_NOP();
 161          Delay_52us_NOP();
 162          Delay_52us_NOP();
 163          Delay_52us_NOP();
 164                    
 165                  for(bitCount = 0; bitCount <8 ; bitCount ++)   // 把起始位算入
 166             {
 167            //  WAITFORKEYBOARDPULSE;     // 等待一个有效的下跳沿
 168            
 169              if(scl_mokuai == 1)
 170            {
 171                KeyCode |= 0x80; // 得到有效的数据位
 172               }
 173                    KeyCode  >>= 1;      // 按照PS2格式,数据低位在前
 174              scl_mokuai  = 1;
 175              sda_mokuai  = 1;
 176                  Delay_52us_NOP();
C51 COMPILER V7.07   MENJING                                                               07/04/2007 23:00:10 PAGE 4   

 177                  Delay_26us_NOP();
 178                  Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();
 179                  Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();
 180                  Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();
 181                  Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();
 182                  Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();
 183                  Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();Delay_52us_NOP();
 184             }
 185          //   WAITFORKEYBOARDPULSE;     // 等待按键发送效验位
 186             WAITFORKEYBOARDPULSE;     // 等待按键发送终止位
 187             while(!scl_mokuai);         // 等待键盘把时钟线拉高
 188                //  switch(KeyCode)
 189          
 190          receive_buf[count]=KeyCode;
 191          SBUF=receive_buf[count]; 
 192          if(receive_buf[count]==ID_code[count]) pass_flag++; 
 193            count++;
 194            if(pass_flag>6){open_door=1;green_led=0;}
 195            if(count>12){count=0x00;pass_flag=0x00;}//
 196            //pass_not();
 197          }
 198          
 199          */
 200          /**********************************************************/
 201          //#include "24C64.c"
 202          
 203          void main(void)
 204          {
 205   1      
 206   1      iniMCU();
 207   1      while(1)
 208   1      {
 209   2      //RI=1;
 210   2      pass_not();
 211   2      /*
 212   2      SBUF=receive_buf[0]; 
 213   2      Delay_52us_NOP();
 214   2      SBUF=receive_buf[1];
 215   2      Delay_52us_NOP(); 
 216   2      SBUF=receive_buf[2];
 217   2      Delay_52us_NOP(); 
 218   2      SBUF=receive_buf[3]; 
 219   2      Delay_52us_NOP();
 220   2      SBUF=receive_buf[4]; 
 221   2      Delay_52us_NOP();
 222   2      SBUF=receive_buf[5];
 223   2      Delay_52us_NOP(); 
 224   2      */
 225   2      }
 226   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    206    ----
   CONSTANT SIZE    =     16    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     17       2
   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 + -