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

📄 main.lst

📁 RFID 使用C8051F020和周立功RC500开发模块
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.20   MAIN                                                                  05/28/2007 14:55:19 PAGE 1   


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

line level    source

   1          #define __SRC
   2          #include "main.h"
   3          #undef  __SRC
   4          
   5          #include "zlg500B.h"
   6          
   7          #define MF1_S50         0                       //卡的类型
   8          #define MF1_S70         1
   9          #define MF0_ULIGHT      2
  10          #define MF1_LIGHT       3
  11          
  12          
  13          sbit zlg500B_RST=P1^3;          //change
  14          sbit LED=P1^4;
  15          /*
  16          sbit TI1   = SCON1 ^ 1;
  17          sbit RI1   = SCON1 ^ 0;
  18          sbit REN1  = SCON1 ^ 4;
  19          */
  20          uchar baud_num;                         //波特率选择序号
  21          uchar keyvalue;                         //从串口和键盘收到的数据
  22          uchar card_snr[8];                      //卡的序列号            //进行两轮验证,
  23          uchar databuf[16];                      //从卡中一个段的数据
  24          uchar adr1,adr2;
  25          uchar *value;
  26          uchar num_key;
  27          uchar keyvalue;
  28          
  29          uchar code Nkey_a[6]={0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5};              //密码
  30          uchar code Nkey_b[6]={0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  31          uchar code Nkey_c[6]={0xee, 0xee, 0xee, 0xee, 0xee, 0xee};              //testkey
  32          
  33          uchar code KEY_CHECK[24]=
  34          {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
  35           0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,
  36           0xBB,0xCC,0xDD,0xEE,
  37          };
  38          
  39          uchar code KEY_MAP[24]=
  40          {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,             //10
  41           'r','w','a','m',                                                                               //4
  42          '?','?','?','?','?','?','?','?','?','?',                 //10
  43          };
  44          
  45          main()
  46          {       
  47   1              
  48   1      
  49   1              uchar cardtype=MF1_S50;         //卡的类型:0
  50   1              uchar status;                           //状态值列表            
  51   1              uchar i,j=40;
  52   1              bit  dosnr=1; 
  53   1              long value=1;
  54   1      
  55   1              //以下对测试变量的定义
C51 COMPILER V7.20   MAIN                                                                  05/28/2007 14:55:19 PAGE 2   

  56   1      //       uchar databufSEQ[16];          //RC500的序列号
  57   1      //       uchar databuf14[16];   
  58   1      //       uchar databuf15[16];
  59   1      
  60   1      //
  61   1          baud_num=2; 
  62   1              F020Config();                           //仅仅完成引脚分配
  63   1              serial_init();          
  64   1              Timer_4_init();
  65   1      
  66   1              for(i=255;i>0;i--)
  67   1                      for(j=10;j>0;j--);
  68   1              zlg500B_RST=0;                                  //对整个系统进行复位
  69   1              for(i=255;i>0;i--)
  70   1                      for(j=20;j>0;j--);      
  71   1      
  72   1          
  73   1              //以下开始对RWD开始进行操作
  74   1              i=mifs_config();                //RWD
  75   1              i=mifs_get_info(databuf);               //读取RC500序列号
  76   1              Uart_1_send(10);
  77   1                                                              
  78   1       //   i=mifs_load_key(KEYA,15,Nkey_a);  //只是写入到RC500的密码
  79   1        //  i=mifs_load_key(KEYA,5,Nkey_b);           //_SecNr所访问卡对应的扇区号
  80   1          
  81   1              
  82   1              //test();
  83   1         // i=mifs_read_E2(0x10,16,databuf);  //不知道为什么,程序到这里就死了,是不延时不对
  84   1      //      i=mifs_read_E2(0x20,16,databuf);                //暂时不读,读也没有用
  85   1      
  86   1      
  87   1      
  88   1              while(1)                //利用查询操作,也可以用其它
  89   1              {       
  90   2                      while(mifs_request(IDLE,databuf)!=MI_OK);               //一直在查有没有卡
  91   2                  //test();
  92   2                      
  93   2                      if(mifs_cascanticoll(ANTICOLL1,0,card_snr)!=MI_OK)      continue;                       //返回卡的序列号了.     
  94   2              
  95   2                      
  96   2                      if(mifs_cascselect(ANTICOLL1,card_snr,&i)!=MI_OK)       continue;
  97   2                      if(i&0x04)                      //
  98   2                      {
  99   3                              if(mifs_cascanticoll(ANTICOLL2,0,card_snr+4)!=MI_OK)    continue;       //第二层防冲突,返回卡的序列号在高字节
 100   3                              if(mifs_cascselect(ANTICOLL2,card_snr+4,&i)!=MI_OK)     continue;                       //进行第二层选择
 101   3                      }
 102   2      
 103   2                      //完成卡的选择,
 104   2                      if(dosnr)       
 105   2                      {
 106   3                              for(i=0;i<4;i++)
 107   3                              {
 108   4                                      databuf[i]=card_snr[1];
 109   4                              }
 110   3                              Uart_1_send(4);
 111   3                              dosnr=0;                        //以后就不重新发了
 112   3                      }
 113   2                      
 114   2                      if(cardtype == MF1_S50)                         //如果是这种卡的话受理,否则不进行受理
 115   2                      {   
 116   3                          status=mifs_authentication(KEYA,15);
 117   3                              if(status!=0)                   continue;               //进行验证
C51 COMPILER V7.20   MAIN                                                                  05/28/2007 14:55:19 PAGE 3   

 118   3                              
 119   3                      }
 120   2                              
 121   2                      
 122   2              
 123   2              }
 124   1      }
 125          
 126                  
 127          
 128                  
 129          
 130          
 131          /****************************************************************************
 132          *                                                                           *
 133          * Function:     serial_init                                                        *
 134          *                                                                           *
 135          * Input:        -                                                           *
 136          * Output:       -                                                           *
 137          *                                                                           *
 138          * Description:                                                              *
 139          *                                                                           *
 140          *                                                                           *
 141          ****************************************************************************/
 142          
 143          void    serial_init (void)
 144          {
 145   1              PCON = 0x00;                    // SMOD = 0;
 146   1              SCON0 = 0x50;                   // Mode 1, 8-bit UART, enable receiption
 147   1              CKCON = 0x00;   // Clock Control Registe        //定时器使用系统时钟12分颁
 148   1          TMOD&=0x0f;                                 //定时器1进行全清零,不管定时器0
 149   1              TMOD|=0x20;                     // Timer 1, mode 2, 8-bit auto reload,
 150   1      
 151   1      
 152   1          TH1=0xFA;                   //波特率的重装值
 153   1      
 154   1      
 155   1          IE        = 0x91;                   //开了所有的中断了
 156   1          EIE2      = 0x40;
 157   1      /*      switch(baud_num)                                //由于实际对波特率进行设置              
 158   1              {       
 159   1                      case 0: TH1=BAUD_2400;  break;  
 160   1                      case 1: TH1=BAUD_4800;  break;
 161   1                      case 2: TH1=BAUD_9600;  break;
 162   1                      case 3: TH1=BAUD_19200; break;
 163   1                      case 4: TH1=BAUD_28800; break;
 164   1                      case 5: TH1=BAUD_57600; break;  
 165   1              }
 166   1      */      
 167   1              CON_485=0;                                              //平时为低,
 168   1              ES0 = 1;                                                        //开串口中断                                    
 169   1              ET1 = 0;                                                //禁定时器1中断
 170   1              TR1 = 1;                                                //开外部中断
 171   1      }
 172          
 173          #pragma noaregs
 174          
 175          /****************************************************************************
 176          *                                                                           *
 177          * Function:     delay_50us                                                  *
 178          *                                                                           *
 179          * Input:        _50us                                                       *
C51 COMPILER V7.20   MAIN                                                                  05/28/2007 14:55:19 PAGE 4   

 180          * Output:       -                                                           *
 181          *                                                                           *
 182          * Description:                                                              *
 183          *                                                                           *
 184          * Time delay with a resolution of 50 us.                                    *
 185          *                                                                           *
 186          ****************************************************************************/
 187          
 188          void    delay_50us (uchar _50us)                        //延时50US
 189          {
 190   1      
 191   1        RCAP2LH = RCAP2_50us;
 192   1        T2LH    = RCAP2_50us;
 193   1        ET2 = 0;      // Disable timer2 interrupt
 194   1        T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
 195   1                                      //开定时器2
 196   1                                      //89C51中并没有定时器2  只有在89C52中才有
 197   1        while (_50us--)
 198   1        {
 199   2              while (!TF2);           //溢出标志:等待溢出标志
 200   2              TF2 = FALSE;                    //溢出标志清零
 201   2        }
 202   1      
 203   1        TR2 = FALSE;                  //关定时器2
 204   1      
 205   1      }
 206          
 207          
 208          /****************************************************************************
 209          *                                                                           *
 210          * Function:     delay_1ms                                                   *
 211          *                                                                           *
 212          * Input:        _1ms                                                        *
 213          * Output:       -                                                           *
 214          *                                                                           *
 215          * Description:                                                              *
 216          *                                                                           *
 217          * Time delay with a resolution of 1 ms.                                     *
 218          *                                                                           *
 219          ****************************************************************************/
 220          
 221          void    delay_1ms (uint _1ms)
 222          {

⌨️ 快捷键说明

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