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

📄 car_cad.lst

📁 用RFM001多页读写32MM的TI玻璃管卡,采用严格的时钟控制
💻 LST
📖 第 1 页 / 共 2 页
字号:
 230   1                RF_write_buf[9] = (uchr)(crc_check & 0x00ff);     //crc的低8位
 231   1                RF_write_buf[10] = (uchr)(crc_check >> 8);             //crc的高8位
 232   1                crc_check = RF_crc(RF_write_buf ,11);         //前11个值的CRC校验值   
 233   1                RF_write_buf[11] = (uchr)(crc_check & 0x00ff);
 234   1                RF_write_buf[12] = (uchr)(crc_check >> 8); 
 235   1                RF_init();
 236   1                RF_charge();
 237   1                for(temp = 0;temp < 13;temp ++)
 238   1                 {
 239   2                      RF_write_byte(RF_write_buf[temp]);
 240   2                 }
 241   1                RF_program();                         //写完之后延时15 ms
C51 COMPILER V8.01   CAR_CAD                                                               07/25/2007 10:26:21 PAGE 5   

 242   1      }
 243          
 244          void RF_comd()
 245          {
 246   1              uchr temp = 0;
 247   1              uchr j = 0;
 248   1              uchr m = 0;
 249   1              uint i = 0;
 250   1      
 251   1      
 252   1      //      memset(RF_write_buf,0,31);
 253   1      //      RF_write_buf[0] = 0x01;                         //包头
 254   1      //      for(temp = 1 ;temp < 9; temp ++)
 255   1      //      {
 256   1      //              RF_write_buf[temp] = RF_read_buf[temp];           //id
 257   1      //      }
 258   1      /*
 259   1              RF_charge();
 260   1                                                              //                                      地址     读命令
 261   1              RF_write_byte(0x08);    //写入第二页读地址(000010 + 00   )     车属单位
 262   1      
 263   1              RF_read();                              //读程序
 264   1              
 265   1              for(temp = 1;temp < 9;temp ++)
 266   1              {
 267   1                      RF_write_buf[temp + 8] = RF_read_buf[temp];
 268   1              }
 269   1      
 270   1              RF_charge();
 271   1                                                              //                                      地址     读命令
 272   1              RF_write_byte(0x0c);    //写入第三页读地址(000011 + 00   )      车号1
 273   1              RF_read();                              //读程序
 274   1              
 275   1              for(temp = 1;temp < 9;temp ++)
 276   1              {
 277   1                      RF_write_buf[temp + 16] = RF_read_buf[temp];
 278   1              }
 279   1      
 280   1              
 281   1              RF_charge();
 282   1                                                              //                                      地址     读命令
 283   1              RF_write_byte(0x10);    //写入第三页读地址(000100 + 00   )       车号2
 284   1              RF_read();                              //读程序
 285   1              
 286   1              for(temp = 1;temp < 5;temp ++)
 287   1              {
 288   1                      RF_write_buf[temp + 24] = RF_read_buf[temp];
 289   1              }
 290   1      
 291   1              i = dallas_CRC_8005(RF_write_buf,29,0);
 292   1              RF_write_buf[29] = ((i >> 8) & 0x00ff);
 293   1              RF_write_buf[30] = (i & 0x00ff);
 294   1       
 295   1              send_string_com(RF_write_buf,31);
 296   1              memset(RF_write_buf,0,31);
 297   1      */
 298   1      }
 299          
 300          void main()
 301          {
 302   1          unsigned char old_buf[9];
 303   1      
C51 COMPILER V8.01   CAR_CAD                                                               07/25/2007 10:26:21 PAGE 6   

 304   1              timer_20ms = 0;
 305   1          rece_ok=0;
 306   1              WORK_LED = 1;
 307   1              OPEN = 1;
 308   1          g_cReceNum=0;
 309   1              memset(RF_read_buf,0,INBUF_LEN);
 310   1              memset(In_buf,0,INBUF_LEN);
 311   1      
 312   1              RF_init();
 313   1       
 314   1              TMOD = 0x21;
 315   1              TL0 = 0;
 316   1              TH0 = 0xB8;
 317   1      //      TR0 = 1;
 318   1      
 319   1              TH1 = 0xFD;
 320   1              TL1 = 0xFD;
 321   1              SCON = 0x50;
 322   1              TR1 = 1;
 323   1              IE = 0x82;
 324   1          IE |= 0x90;
 325   1          while(1)
 326   1          {
 327   2           if(rece_ok==0)
 328   2             continue;
 329   2              memset(RF_read_buf,0,INBUF_LEN);
 330   2           send_char_com(In_buf[0]);
 331   2               switch(In_buf[0])
 332   2                {
 333   3             case 0x55:  //读玻璃管卡ID
 334   3                              RF_charge();
 335   3                                                                      //                                      地址     读命令
 336   3                              RF_write_byte(0x04);    //写入第一页读地址(000001 + 00   )
 337   3                      
 338   3                              RF_read();                              //读程序
 339   3                              RF_comd();
 340   3                 break;
 341   3             case 0x56:  //读签卡单位
 342   3                              RF_charge();
 343   3                                                                      //                                      地址     读命令
 344   3                              RF_write_byte(0x08);    //写入第二页读地址(000001 + 00   )
 345   3                      
 346   3                              RF_read();                              //读程序
 347   3                              RF_comd();
 348   3                 break;
 349   3             case 0x57:  //读车牌号(8)+(4)
 350   3                              RF_charge();
 351   3                                                                      //                                      地址     读命令
 352   3                              RF_write_byte(0x0c);    //写入第二页读地址(000001 + 00   )
 353   3                      
 354   3                              RF_read();                              //读程序
 355   3                              RF_comd();
 356   3                 break;
 357   3                 case 0x66:  //写玻璃管卡ID)
 358   3                      memcpy(old_buf,In_buf+2,8);
 359   3                      RF_write(0,In_buf+2);
 360   3      
 361   3                              RF_read();                              //读程序
 362   3                              RF_comd();
 363   3                  if(memcmp(old_buf,RF_read_buf+1,8))
 364   3                              { 
 365   4                               send_string_com("\xAA\x01",2);
C51 COMPILER V8.01   CAR_CAD                                                               07/25/2007 10:26:21 PAGE 7   

 366   4                               send_string_com(old_buf,8);
 367   4                   send_string_com(RF_read_buf+1,8);
 368   4                          }
 369   3                              else
 370   3                              {
 371   4                               send_string_com("\xAA\x00",2);
 372   4                              }
 373   3                  break;
 374   3                 case 0x67:  //签卡单位(8)
 375   3                      memcpy(old_buf,In_buf+2,8);
 376   3                      RF_write(1,In_buf+2);
 377   3      
 378   3                              RF_read();                              //读程序
 379   3                              RF_comd();
 380   3                  if(memcmp(old_buf,RF_read_buf+1,8))
 381   3                              { 
 382   4                               send_string_com("\xAA\x01",2);
 383   4                               send_string_com(old_buf,8);
 384   4                   send_string_com(RF_read_buf+1,8);
 385   4                          }
 386   3                              else
 387   3                              {
 388   4                               send_string_com("\xAA\x00",2);
 389   4                              }
 390   3                  break;
 391   3      /*         case 0x68:  //车牌号(12)
 392   3                      memcpy(old_buf,In_buf+2,12);
 393   3                      RF_write(In_buf+2);
 394   3      
 395   3                              RF_read();                              //读程序
 396   3                              RF_comd();
 397   3                  if(memcmp(old_buf,RF_read_buf+1,12))
 398   3                              { 
 399   3                               send_string_com("\xAA\x01",2);
 400   3                               send_string_com(old_buf,12);
 401   3                   send_string_com(RF_read_buf+1,12);
 402   3                          }
 403   3                              else
 404   3                              {
 405   3                               send_string_com("\xAA\x00",2);
 406   3                              }
 407   3                  break;
 408   3      */
 409   3                 default:    //缺省
 410   3                        break;
 411   3                }
 412   2               g_cReceNum=0;
 413   2           rece_ok=0;
 414   2           ES=1;
 415   2          }
 416   1      }
 417           
 418          void timer0 (void) interrupt 1 
 419          { 
 420   1              TL0 = 0;
 421   1              TH0 = 0xB8;
 422   1              timer_20ms = 1;
 423   1      }
 424          
 425          
 426           
 427          /////////////////////////////////////////////////////////////////////
C51 COMPILER V8.01   CAR_CAD                                                               07/25/2007 10:26:21 PAGE 8   

 428          //串行中断,接收上位机数据
 429          /////////////////////////////////////////////////////////////////////
 430          seri_int () interrupt 4 using 1
 431          {
 432   1         unsigned char rece_data = SBUF;
 433   1         unsigned char verify = 0;
 434   1      
 435   1         if (RI)
 436   1         {    
 437   2             RI = 0;
 438   2             In_buf[g_cReceNum++]=rece_data;
 439   2                 if(g_cReceNum>INBUF_LEN)
 440   2                   g_cReceNum=0;
 441   2             if(g_cReceNum==(In_buf[1]+3))  //句柄1+长度(1)+数据(N)+疑惑校验(1)
 442   2                  {
 443   3                   rece_ok=1;
 444   3                       ES=0;
 445   3                      }           
 446   2          }
 447   1          if (TI)
 448   1          {   TI = 0;   }
 449   1      }
 450          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    893    ----
   CONSTANT SIZE    =      6    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     53      49
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      5    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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