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

📄 main.lst

📁 基于RS232的键盘,也可以作为输入输出的操作面板,用于数控系统开发
💻 LST
📖 第 1 页 / 共 5 页
字号:
 411                                          tmpptr--;               \
 412                                          (*tmpptr)++;            \
 413                                          if ( !(*tmpptr) )       \
 414                                          {                                       \
 415                                                  tmpptr--;               \
 416                                                  (*tmpptr)++;    \
 417                                          }               \
 418                                  }                       \
 419                          }                               \
 420                  } while( 0 )
C51 COMPILER V7.04   MAIN                                                                  01/23/2007 12:25:24 PAGE 8   

 421          
 422                  
 423          void timer_0(void) interrupt 1 using 2
 424          {
 425   1              TimerEndTmpFlag = 0;
 426   1              if ( Timer0EndIntFlag )
 427   1              {
 428   2                      Timer[0].IntCnt = 0;
 429   2                      TimerEndTmpFlag = 1;
 430   2                      if ( Timer[0].SecConstFlag )
 431   2                      {
 432   3                              Timer[0].TimerConstCntH = Timer[0].SecTimerConstCntH;
 433   3                              Timer[0].TimerConstH = Timer[0].SecTimerConstH;
 434   3                              Timer[0].TimerConstL = Timer[0].SecTimerConstL;
 435   3                              Timer[0].SecConstFlag = 0;
 436   3                      }               
 437   2              }
 438   1      
 439   1              TR0 = 0;
 440   1              if ( Timer[0].IntCnt == Timer[0].TimerConstCntH )
 441   1          {
 442   2                      Timer0EndIntFlag = 1;
 443   2      
 444   2                      TL0 += Timer[0].TimerConstL;
 445   2                      TH0 = Timer[0].TimerConstH;
 446   2              }
 447   1              else
 448   1              {
 449   2                      Timer0EndIntFlag = 0;
 450   2              }
 451   1              TR0 = 1;
 452   1              Timer[0].IntCnt++;
 453   1      
 454   1              if ( !TimerEndTmpFlag )
 455   1                      return;
 456   1      
 457   1              if ( Timer[0].UpDwonCnt )
 458   1                      Timer[0].UpDwonCnt--;
 459   1      
 460   1              switch( Timer[0].MotorIdx )
 461   1              {
 462   2                      // 电机0
 463   2                      case 1:
 464   2                              if ( MotorStatus[0].Status & MOTOR_STOP_CMD_MASK )
 465   2                              {
 466   3                                      // 双向
 467   3                                      if ( (MotorStatus[0].Dir & DIR_FLAG_MASK) == DIR_FLAG_MASK )
 468   3                                      {
 469   4                                              if ( Timer[0].CenrerPluse == (WORD)MotorStatus[0].TotalPluseCnt )
 470   4                                              {
 471   5                                                      // 只保留零点记录标志
 472   5                                                      MotorStatus[0].Status &= ZERO_RECORD_MASK;      
 473   5                                                      MotorStatus[0].Dir = 0;
 474   5      
 475   5                                                      // 关定时器0
 476   5                                                      TR0 = 0;
 477   5                                                      ET0 = 0;
 478   5                                                      Timer[0].MotorIdx = 0;
 479   5                                                      break;
 480   5                                              }
 481   4                                      }
 482   3                                      else
C51 COMPILER V7.04   MAIN                                                                  01/23/2007 12:25:24 PAGE 9   

 483   3                                      {
 484   4                                              // 只保留零点记录标志
 485   4                                              MotorStatus[0].Status &= ZERO_RECORD_MASK;      
 486   4                                              MotorStatus[0].Dir = 0;
 487   4              
 488   4                                              // 关定时器0
 489   4                                              TR0 = 0;
 490   4                                              ET0 = 0;
 491   4                                              Timer[0].MotorIdx = 0;
 492   4                                              PUL0 = 1;
*** ERROR C202 IN LINE 492 OF MAIN.C: 'PUL0': undefined identifier
 493   4                                              break;
 494   4                                      }
 495   3                              }
 496   2                      
 497   2                              // 改变输出电平
 498   2                              PUL0 = ~PUL0;
*** ERROR C202 IN LINE 498 OF MAIN.C: 'PUL0': undefined identifier
 499   2              
 500   2                              // 增减脉冲总数量
 501   2                              tmpptr = (BYTE idata*)&MotorStatus[0].TotalPluseCnt + LSB;
 502   2                              if ( DIR0 )
*** ERROR C202 IN LINE 502 OF MAIN.C: 'DIR0': undefined identifier
 503   2                                      DWordDec( );
 504   2                              else
 505   2                                      DWordInc( );
 506   2      
 507   2                              // 当前脉冲减
 508   2                              tmpptr = (BYTE idata*)&Timer[0].CurPluseNum + LSB;
 509   2                              DWordDec( );
 510   2      
 511   2                              // 零位检测
 512   2                              if ( MotorStatus[0].Status & ZERO_CHECK_MASK )
 513   2                              {
 514   3                                      // 零位到达
 515   3                                      if ( !LastTimer0ST && ST0 )
*** ERROR C202 IN LINE 515 OF MAIN.C: 'P2_0': undefined identifier
 516   3                                      {
 517   4                                              MotorStatus[0].Status |= MOTOR_STOP_CMD_MASK;
 518   4                                              MotorStatus[0].Status |= ZERO_RECORD_MASK;
 519   4                                              MotorStatus[0].TotalPluseCnt = 0;
 520   4                                              break;
 521   4                                      }
 522   3                                      LastTimer0ST = ST0;
*** ERROR C202 IN LINE 522 OF MAIN.C: 'P2_0': undefined identifier
 523   3                              }
 524   2                              
 525   2                              // 脉冲数未完
 526   2                              if ( Timer[0].CurPluseNum )
 527   2                                      break;
 528   2                                      
 529   2                              if ( (MotorStatus[0].Dir & DIR_FLAG_MASK) == DIR_FLAG_MASK )
 530   2                              {
 531   3                                      DIR0 = ~DIR0;
*** ERROR C202 IN LINE 531 OF MAIN.C: 'DIR0': undefined identifier
 532   3                                      Timer[0].CurPluseNum = MotorStatus[0].CmdPluseNum;
 533   3                              }
 534   2                              else
 535   2                              {
 536   3                                      // 停止
 537   3                                      MotorStatus[0].Status |= MOTOR_STOP_CMD_MASK;
 538   3                              }
C51 COMPILER V7.04   MAIN                                                                  01/23/2007 12:25:24 PAGE 10  

 539   2                              break;
 540   2      
 541   2                      // 电机1
 542   2                      case 2:
 543   2                              if ( MotorStatus[1].Status & MOTOR_STOP_CMD_MASK )
 544   2                              {
 545   3                                      if ( (MotorStatus[1].Dir & DIR_FLAG_MASK) == DIR_FLAG_MASK )
 546   3                                      {
 547   4                                              if ( Timer[0].CenrerPluse == (WORD)MotorStatus[1].TotalPluseCnt )
 548   4                                              {
 549   5                                                      // 只保留零点记录标志
 550   5                                                      MotorStatus[1].Status &= ZERO_RECORD_MASK;      
 551   5                                                      MotorStatus[1].Dir = 0;
 552   5      
 553   5                                                      // 关定时器0
 554   5                                                      TR0 = 0;
 555   5                                                      ET0 = 0;
 556   5                                                      Timer[0].MotorIdx = 0;
 557   5                                                      break;
 558   5                                              }
 559   4                                      }
 560   3                                      else
 561   3                                      {
 562   4                                              // 只保留零点记录标志
 563   4                                              MotorStatus[1].Status &= ZERO_RECORD_MASK;      
 564   4                                              MotorStatus[1].Dir = 0;
 565   4              
 566   4                                              // 关定时器0
 567   4                                              TR0 = 0;
 568   4                                              ET0 = 0;
 569   4                                              Timer[0].MotorIdx = 0;
 570   4                                              PUL1 = 1;
*** ERROR C202 IN LINE 570 OF MAIN.C: 'PUL1': undefined identifier
 571   4                                              break;
 572   4                                      }
 573   3                              }
 574   2                      
 575   2                              // 改变输出电平
 576   2                              PUL1 = ~PUL1;
*** ERROR C202 IN LINE 576 OF MAIN.C: 'PUL1': undefined identifier
 577   2              
 578   2                              // 增减脉冲总数量
 579   2                              tmpptr = (BYTE idata*)&MotorStatus[1].TotalPluseCnt + LSB;
 580   2                              if ( DIR1 )
*** ERROR C202 IN LINE 580 OF MAIN.C: 'DIR1': undefined identifier
 581   2                                      DWordDec( );
 582   2                              else
 583   2                                      DWordInc( );
 584   2      
 585   2                              // 当前脉冲减
 586   2                              tmpptr = (BYTE idata*)&Timer[0].CurPluseNum + LSB;
 587   2                              DWordDec( );
 588   2      
 589   2                              // 零位检测
 590   2                              if ( MotorStatus[1].Status & ZERO_CHECK_MASK )
 591   2                              {
 592   3                                      // 零位到达
 593   3                                      if ( !LastTimer0ST && ST1 )
*** ERROR C202 IN LINE 593 OF MAIN.C: 'P2_1': undefined identifier
 594   3                                      {
 595   4                                              MotorStatus[1].Status |= MOTOR_STOP_CMD_MASK;
 596   4                                              MotorStatus[1].Status |= ZERO_RECORD_MASK;
C51 COMPILER V7.04   MAIN                                                                  01/23/2007 12:25:24 PAGE 11  

 597   4                                              MotorStatus[1].TotalPluseCnt = 0;
 598   4                                              break;
 599   4                                      }
 600   3                                      LastTimer0ST = ST1;
*** ERROR C202 IN LINE 600 OF MAIN.C: 'P2_1': undefined identifier
 601   3                              }
 602   2      
 603   2                              // 脉冲数未完
 604   2                              if ( Timer[0].CurPluseNum )
 605   2                                      break;
 606   2                                      
 607   2                              if ( (MotorStatus[1].Dir & DIR_FLAG_MASK) == DIR_FLAG_MASK )
 608   2                              {
 609   3                                      DIR1 = ~DIR1;
*** ERROR C202 IN LINE 609 OF MAIN.C: 'DIR1': undefined identifier

⌨️ 快捷键说明

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