C51 COMPILER V9.52.0.0   INTERRUPT                                                         09/25/2018 16:17:01 PAGE 1   


C51 COMPILER V9.52.0.0, COMPILATION OF MODULE INTERRUPT
OBJECT MODULE PLACED IN .\Output\Interrupt.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\User\Source\Application\Interrupt.c LARGE OMF2 WARNINGLEVEL(0) BROWSE IN
                    -CDIR(..\Library\FU68xx_Hardware_Driver\Include;..\User\Include) DEBUG PRINT(.\Listing\Interrupt.lst) OBJECT(.\Output\Int
                    -errupt.obj)

line level    source

   1          /**************************** (C) COPYRIGHT 2017 Fortiortech shenzhen *****************************
   2          * File Name          : Interrupt.c
   3          * Author             : Vina Peng,Fortiortech  Appliction Team
   4          * Version            : V1.0
   5          * Date               : 2017-12-26
   6          * Description        : This file contains all the interrupt function used for Motor Control.
   7          ***************************************************************************************************
   8          * All Rights Reserved
   9          **************************************************************************************************/
  10          
  11          
  12          /* Includes -------------------------------------------------------------------------------------*/
  13          // #include <Interrupt.h>
  14          #include <FU68xx_2.h>
  15          #include <Myproject.h>
  16          #include <Customer_Debug.h>
  17          uint16 xdata spidebug[4] = { 0 };
  18          
  19          
  20          /*-------------------------------------------------------------------------------------------------
  21              Function Name : void FO_INT(void)
  22              Description   : FO_INT interrupt，硬件FO过流保护，关断输出，中断优先级最高
  23              Input         : 无
  24                          Output        : 无
  25          -------------------------------------------------------------------------------------------------*/
  26          void FO_INT(void) interrupt 1                                                   // 硬件FO过流中断，
             -关闭输出
  27          {
  28   1      //    FaultProcess();                                                             // 关闭输出
  29   1      //    mcFaultSource = FaultHardOVCurrent;                                         // 硬件过流保护
  30   1      //    mcState       = mcFault;                                                    // 状态为mcFault
  31   1          
  32   1          dimmer_cnt = 0;
  33   1          IF0           = 0;                                                          // clear P00 interrupt fla
             -g
  34   1      }
  35          /*-------------------------------------------------------------------------------------------------
  36              Function Name : void CMP_ISR(void)
  37              Description   : CMP3：硬件比较器过流保护，关断输出，中断优先级最高
  38                                                                                          CMP0/1/2：顺逆风判断
  39              Input         : 无
  40                          Output        : 无
  41          -------------------------------------------------------------------------------------------------*/
  42          void CMP_ISR(void) interrupt 7
  43          {
  44   1          if(ReadBit(CMP_SR, CMP3IF))
  45   1          {
  46   2              if(mcState!=mcPosiCheck)
  47   2              {
  48   3                  FaultProcess();                                                     // 关闭输出
  49   3                  mcFaultSource=FaultHardOVCurrent;                                   // 硬件过流保护
  50   3                  mcState = mcFault;                                                  // 状态为mcFault
  51   3              }
C51 COMPILER V9.52.0.0   INTERRUPT                                                         09/25/2018 16:17:01 PAGE 2   

  52   2              else
  53   2              {
  54   3                  MOE     = 0;                                                                        // 关闭M
             -OE
  55   3                  RPDPara.InsetCount[RPDPara.injecttimes]  = TIM2__CNTR;                              // 将定�
             -��器2的计数值赋值给数组
  56   3                  RPDPara.DetectCount[RPDPara.injecttimes] = RPDPara.InsetCount[RPDPara.injecttimes]; // 两组�
             -��据，一组用于观察原始数据，一组用于处理数据
  57   3                  TIM2__CNTR                               = 0;                                       // TIM2计
             -数器值清零
  58   3                  RPDPara.injecttimes++;                                                              // RPD注�
             -��拍数累加
  59   3      
  60   3              }
  61   2              ClrBit(CMP_SR, CMP3IF);
  62   2          }
  63   1      
  64   1          #if (FRDetectMethod == BEMFMethod)
                      //通过BEMF做顺风启动功能
                      BEMFDetectFunc();
                  #endif
  68   1      }
  69          
  70          /*---------------------------------------------------------------------------*/
  71          /* Name     :   void TIM2_INT(void) interrupt 4
  72          /* Input    :   NO
  73          /* Output   :   NO
  74          /* Description: 正反转检测(RSD)
  75          /*---------------------------------------------------------------------------*/
  76          void TIM2_INT(void) interrupt 4
  77          {
  78   1          if(ReadBit(TIM2_CR1, T2IR))
  79   1          {
  80   2              ClrBit(TIM2_CR1, T2IR);
  81   2          }
  82   1          if(ReadBit(TIM2_CR1, T2IP))
  83   1          {
  84   2              #if (FRDetectMethod == RSDMethod)
                          RSDFRDetect();//RSD正反转检测
                      #endif
  87   2      
  88   2              ClrBit(TIM2_CR1, T2IP);
  89   2          }
  90   1          if(ReadBit(TIM2_CR1, T2IF))//溢出中断,用于判断静止,时间为349ms。
  91   1          {
  92   2              #if (FRDetectMethod == RSDMethod)
                          RSDDetect.RSDState=Static;
                          RSDDetect.RSDFlag=1;
                      #endif
  96   2      
  97   2              ClrBit(TIM2_CR1, T2IF);
  98   2          }
  99   1      }
 100          /*---------------------------------------------------------------------------*/
 101          /* Name     :   void TIM23_INT(void) interrupt 9
 102          /* Input    :   NO
 103          /* Output   :   NO
 104          /* Description: Capture PWM ，中断优先级第二，高于FOC中断，用于PWM调速
 105          /*---------------------------------------------------------------------------*/
 106          void TIM3_INT(void) interrupt 9
 107          {
 108   1          if(ReadBit(TIM3_CR1, T3IR))
C51 COMPILER V9.52.0.0   INTERRUPT                                                         09/25/2018 16:17:01 PAGE 3   

 109   1          {
 110   2              ClrBit(TIM3_CR1, T3IR);
 111   2          }
 112   1          if(ReadBit(TIM3_CR1, T3IP))//周期中断
 113   1          {
 114   2              RFValue();
 115   2              ClrBit(TIM3_CR1, T3IP);
 116   2          }
 117   1          if(ReadBit(TIM3_CR1, T3IF))
 118   1          {
 119   2                      ClrBit(TIM3_CR1, T3EN);
 120   2                      TIM3__ARR = 0;                                                                                                  // TIM3 Period = 100us                          
 121   2                      TIM3__DR = 0;                                                                                                                                   // 1个PWM产生匹配
 122   2                      TIM3__CNTR = 0;
 123   2                      
 124   2                      IRScan.BitCnt = 0;
 125   2                      IRScan.ByteValue = 0;           
 126   2                      IRScan.CurrentDataCode = 0;             
 127   2                      IRScan.OldDataCodeMixTimes =0;                                                                                                  //重复按键清零
 128   2                      IRScan.OverFlowStatus=0;
 129   2              
 130   2                      IRScan.TempDataCode[0]=0;
 131   2                      IRScan.TempDataCode[1]=0;       
 132   2                      IRScan.TempDataCode[2]=0;
 133   2                      IRScan.TempDataCode[3]=0;               
 134   2                      IRScan.DataCodeNum = 0;
 135   2              ClrBit(TIM3_CR1, T3IF);
 136   2                      SetBit(TIM3_CR1, T3EN);
 137   2          }
 138   1      }
 139          /*---------------------------------------------------------------------------*/
 140          /* Name     :   void FOC_INT(void) interrupt 3
 141          /* Input    :   NO
 142          /* Output   :   NO
 143          /* Description: FOC中断(Drv中断),每个载波周期执行一次，用于处理响应较高的程序，
             -中断优先级第二。DCEN开了就会产生中断。
 144          /*---------------------------------------------------------------------------*/
 145          void FOC_INT(void) interrupt 3
 146          {
 147   1          if(ReadBit(DRV_SR, DCIF))                                 // 比较中断
 148   1          {
 149   2              APP_DIV();      //启动除法器，避免与过调值中的除法冲突
 150   2      
 151   2              Fault_Overcurrent(&mcCurVarible); // 软件过流保护.约30us
 152   2      
 153   2              #if ((FRDetectMethod == FOCMethod) && (TailWind_Mode == TailWind))
 154   2                  TailWindSpeedDetect();      //顺逆风检测
 155   2              #endif
 156   2      
 157   2              #if defined (SPI_DBG_SW)        //软件调试模式
                          spidebug[0] = 0;
                          spidebug[1] = 0;
                          spidebug[2] = 0;
                          spidebug[3] = SOFT_SPIDATA3;
                      #endif
 163   2      
 164   2              ClrBit(DRV_SR, DCIF);
 165   2          }
 166   1      }
 167          
 168          /*---------------------------------------------------------------------------*/
 169          /* Name     :   void TIM4S_INT(void) interrupt 10
C51 COMPILER V9.52.0.0   INTERRUPT                                                         09/25/2018 16:17:01 PAGE 4   

 170          /* Input    :   NO
 171          /* Output   :   NO
 172          /* Description: 1ms定时器中断（SYS TICK中断），用于处理附加功能，如控制环路响应�
             -��各种保护等。中断优先级低于FO中断和FOC中断。
 173          /*---------------------------------------------------------------------------*/
 174          void TIM4S_INT(void) interrupt 10
 175          {
 176   1          if(ReadBit(TIM4_CR1, T4IF))//定时器4中断  调光
 177   1          {
 178   2              Dimmer_Control();
 179   2              GP37 = ~GP37;
 180   2              ClrBit(TIM4_CR1, T4IF);
 181   2          }
 182   1          
 183   1          if(ReadBit(DRV_SR, SYSTIF))          // SYS TICK中断
 184   1          {
 185   2              SetBit(ADC_CR, ADCBSY);          //使能ADC的DCBUS采样
 186   2              /****功率滤波*****/
 187   2              if(mcState == mcRun)
 188   2              {
 189   3                  mcFocCtrl.CurrentPower = FOC__POW << 1;
 190   3                  mcFocCtrl.Powerlpf     = LPFFunction(mcFocCtrl.CurrentPower,mcFocCtrl.Powerlpf,10);//注意低
             -通滤波器系数范围为0---127
 191   3              }
 192   2      
 193   2              /****速度滤波、反电动势滤波*****/
 194   2              if((mcState != mcInit) && (mcState != mcReady))
 195   2              {
 196   3                  mcFocCtrl.SpeedFlt = LPFFunction(FOC__EOME, mcFocCtrl.SpeedFlt, 10);//注意低通滤波器系
             -数范围为0---127
 197   3                  mcFocCtrl.EsValue  = LPFFunction(FOC__ESQU,mcFocCtrl.EsValue,10);
 198   3              }
 199   2              else
 200   2              {
 201   3                  mcFocCtrl.SpeedFlt = 0;
 202   3              }
 203   2      
 204   2                      //正反转控制
 205   2                      FRControl();
 206   2                      
 207   2                      //红外遥控处理
 208   2                      IRScanControl();
 209   2                              
 210   2                      NatureWind();
 211   2      
 212   2                      AutoPowerControl();
 213   2                      
 214   2              Speed_response();        //环路响应，如速度环、转矩环、功率环等
 215   2      
 216   2              #if (StartONOFF_Enable)
                          ONOFF_Starttest(&ONOFFTest);
                      #endif
 219   2      
 220   2              /*****DCbus的采样获取值并滤波******/
 221   2              AdcSampleValue.ADCDcbus = ADC2_DR;
 222   2              mcFocCtrl.mcDcbusFlt    = LPFFunction((AdcSampleValue.ADCDcbus<<3),mcFocCtrl.mcDcbusFlt,12);
 223   2      
 224   2              /*****故障保护函数功能，如过欠压保护、启动保护、缺相、堵转等********/
 225   2              Fault_Detection();
 226   2                      
 227   2                      //刹车电流归零检测
 228   2                      CurrentZeroDetect();
C51 COMPILER V9.52.0.0   INTERRUPT                                                         09/25/2018 16:17:01 PAGE 5   

 229   2      
 230   2             //电压在正常值以上时才允许控制蜂鸣器和继电器，防止掉电时电压波动影�
             -��
 231   2                      //if(mcFocCtrl.mcDcbusFlt > UNDER_RECOVER_VALUE)
 232   2                      {
 233   3                              //LED灯控
 234   3                              LEDDisplay();
 235   3                              
 236   3                              //蜂鸣器TIM2 P10
 237   3                              BuzzerScan();
 238   3                      }
 239   2      
 240   2              /****模拟调速****/
 241   2              #if (SPEED_MODE == SREFMODE)
                          VSPSample();
                      #endif
 244   2      
 245   2              /********睡眠模式*******/
 246   2      //    Sleepmode();
 247   2      
 248   2              /*****电机状态机的时序处理*****/
 249   2              if(mcFocCtrl.State_Count > 0)      mcFocCtrl.State_Count--;
 250   2              if(BEMFDetect.BEMFTimeCount > 0)   BEMFDetect.BEMFTimeCount--;
 251   2              if(RSDDetect.RSDCCWSBRCnt > 0)     RSDDetect.RSDCCWSBRCnt--;
 252   2                      if(Time.PowerUpTimeCount<60000)    Time.PowerUpTimeCount++;  //上电一分钟计时
 253   2                      
 254   2              #if (FRDetectMethod==FOCMethod)
 255   2                  FOCTailWindTimeLimit();
 256   2              #endif
 257   2                      
 258   2                      if(mcState == mcRun)
 259   2                      {
 260   3                              //Run状态计时
 261   3                              if(Time.mcRunStateCount<60000)
 262   3                              {
 263   4                                      Time.mcRunStateCount++;
 264   4                              }
 265   3                              //正反转自动测试
 266   3                              if(Time.mcRunStateCount == 6000)
 267   3                              {
 268   4                                      IRControl.FlagFR=1;
 269   4      //                              ONOFFTIMES++;
 270   4                              }
 271   3                      }
 272   2                      else
 273   2                      {
 274   3                              Time.mcRunStateCount=0;
 275   3                      }
 276   2                      
 277   2              /*****电机启动爬坡函数处理*****/
 278   2              StarRampDealwith();
 279   2              
 280   2              ClrBit(DRV_SR, SYSTIF);                                      // 清零标志位
 281   2          }
 282   1      }
 283          
 284          /*---------------------------------------------------------------------------*/
 285          /* Name     :   void USART_INT(void) interrupt 12
 286          /* Input    :   NO
 287          /* Output   :   NO
 288          /* Description: 串口中断，中断优先级最低，用于接收调速信号,无中断插入时8us
 289          /*---------------------------------------------------------------------------*/
C51 COMPILER V9.52.0.0   INTERRUPT                                                         09/25/2018 16:17:01 PAGE 6   

 290          void USART_INT(void)  interrupt 12
 291          {
 292   1          if(RI == 1)
 293   1          {
 294   2              RI = 0;
 295   2              Uart.Uredata= UT_DR;            //读接收数据
 296   2          }
 297   1      }
 298          /*---------------------------------------------------------------------------*/
 299          /* Name     :   void EXTERN_INT(void) interrupt 2
 300          /* Input    :   NO
 301          /* Output   :   NO
 302          /* Description: 睡眠唤醒
 303          /*---------------------------------------------------------------------------*/
 304          void EXTERN_INT(void) interrupt 2
 305          {
 306   1          if(SleepSet.SleepFlag)
 307   1          {
 308   2              SleepSet.SleepFlag = 0;
 309   2              SleepSet.SleepEn   = 1;
 310   2          }
 311   1      
 312   1          ClrBit(P1_IF, P11);                    // 清零P10标志位
 313   1      }
 314          
 315          
 316          /* Private variables ----------------------------------------------------------------------------*/
 317          void INT0(void) interrupt 0
 318          {
 319   1      }
 320          void INT5(void) interrupt 5
 321          {
 322   1      }
 323          void INT6(void) interrupt 6
 324          {
 325   1      }
 326          void INT8(void) interrupt 8
 327          {
 328   1      }
 329          void INT11(void) interrupt 11
 330          {
 331   1      }
 332          void INT13(void) interrupt 13
 333          {
 334   1      }
 335          void INT14(void) interrupt 14
 336          {
 337   1      }
 338          void INT15(void) interrupt 15
 339          {
 340   1      }
 341          
 342          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1158    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =      8    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
C51 COMPILER V9.52.0.0   INTERRUPT                                                         09/25/2018 16:17:01 PAGE 7   

   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


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