C51 COMPILER V9.52.0.0   FU68XX_2_OTHER                                                    08/29/2018 19:34:24 PAGE 1   


C51 COMPILER V9.52.0.0, COMPILATION OF MODULE FU68XX_2_OTHER
OBJECT MODULE PLACED IN .\Output\Fu68xx_2_Other.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\Library\FU68xx_Hardware_Driver\Source\Fu68xx_2_Other.c LARGE OMF2 WARNIN
                    -GLEVEL(0) OPTIMIZE(5,SPEED) BROWSE INCDIR(..\Library\FU68xx_Hardware_Driver\Include;..\User\Include) DEBUG PRINT(.\Listi
                    -ng\Fu68xx_2_Other.lst) TABS(2) OBJECT(.\Output\Fu68xx_2_Other.obj)

line level    source

   1          /******************** (C) COPYRIGHT 2017 Fortiortech shenzhen******************
   2          * File Name          : SealLib.c
   3          * Author             : Fortiortech  Appliction Team
   4          * Version            : V1.0
   5          * Date               : 10-Apr-2017
   6          * Description        : This file contains init position detection used for
   7          *                      Motor Control.
   8          ********************************************************************************
   9          * All Rights Reserved
  10          *
  11          *******************************************************************************/
  12          #include <FU68xx_2.h>
  13          #include <Myproject.h>
  14          
  15          
  16          /*---------------------------------------------------------------------------*/
  17          /* Name   : int16 RPD(int16 value)
  18          /* Input  : value
  19          /* Output : int16
  20          /* Description:RPD send drvier wave
  21          /*---------------------------------------------------------------------------*/
  22          void RPD_0_VWinit(void)//VW
  23          {
  24   1            DRV_CMR  = 0x00;
  25   1            DRV_CMR |= 0x18;
  26   1      }
  27          void RPD_1_WVinit(void)//WV
  28          {
  29   1            DRV_CMR  = 0x00;
  30   1            DRV_CMR |= 0x24;
  31   1      }
  32          void RPD_2_UVinit(void)//UV
  33          {
  34   1            DRV_CMR  = 0x00;
  35   1            DRV_CMR |= 0x06;
  36   1      }
  37          void RPD_3_VUinit(void)//VU
  38          {
  39   1            DRV_CMR  = 0x00;
  40   1            DRV_CMR |= 0x09;
  41   1      }
  42          void RPD_4_WUinit(void)//WU
  43          {
  44   1            DRV_CMR  = 0x00;
  45   1            DRV_CMR |= 0x21;
  46   1      }
  47          void RPD_5_UWinit(void)//UW
  48          {
  49   1            DRV_CMR  = 0x00;
  50   1            DRV_CMR |= 0x12;
  51   1      }
  52          
  53          
C51 COMPILER V9.52.0.0   FU68XX_2_OTHER                                                    08/29/2018 19:34:24 PAGE 2   

  54          
  55          /*---------------------------------------------------------------------------*/
  56          /* Name   : int16 RPD_Inject(int16 value)
  57          /* Input  : value
  58          /* Output : int16
  59          /* Description:RPD注入方法及判断
  60          /*---------------------------------------------------------------------------*/
  61          void RPD_Inject(void)
  62          {
  63   1        switch(RPD_Status)
  64   1        {
  65   2          case RPD_0:
  66   2            {
  67   3              RPD_0_VWinit();
  68   3              RPD_Status=RPD_1;
  69   3              #if (Shunt_Resistor_Mode == Three_Resistor)
                      {
                      DAC_DR = DAC_RPDCurValue+RPDPara.W_Offset-0x7F;
                      }
                      #endif
  74   3            }
  75   2            break;
  76   2          case RPD_1:
  77   2           {
  78   3              RPD_1_WVinit();
  79   3              RPD_Status=RPD_2;
  80   3              #if (Shunt_Resistor_Mode == Three_Resistor)
                      {
                         DAC_DR = DAC_RPDCurValue+RPDPara.V_Offset-0x7F;
                      }
                      #endif
  85   3            }
  86   2            break;
  87   2          case RPD_2:
  88   2            {
  89   3              RPD_2_UVinit();
  90   3              RPD_Status=RPD_3;
  91   3              #if (Shunt_Resistor_Mode == Three_Resistor)
                      {
                        DAC_DR = DAC_RPDCurValue+RPDPara.V_Offset-0x7F;
                      }
                      #endif
  96   3            }
  97   2            break;
  98   2          case RPD_3:
  99   2            {
 100   3              RPD_3_VUinit();
 101   3              RPD_Status=RPD_4;
 102   3              #if (Shunt_Resistor_Mode == Three_Resistor)
                      {
                        DAC_DR = DAC_RPDCurValue+RPDPara.U_Offset-0x7F;
                      }
                      #endif
 107   3            }
 108   2            break;
 109   2          case RPD_4:
 110   2           {
 111   3              RPD_4_WUinit();
 112   3              RPD_Status=RPD_5;
 113   3              #if (Shunt_Resistor_Mode == Three_Resistor)
                      {
                        DAC_DR = DAC_RPDCurValue+RPDPara.U_Offset-0x7F;
C51 COMPILER V9.52.0.0   FU68XX_2_OTHER                                                    08/29/2018 19:34:24 PAGE 3   

                      }
                      #endif
 118   3            }
 119   2            break;
 120   2          case RPD_5:
 121   2            {
 122   3              RPD_5_UWinit();
 123   3              RPD_Status=RPD_6;
 124   3              #if (Shunt_Resistor_Mode == Three_Resistor)
                      {
                        DAC_DR = DAC_RPDCurValue+RPDPara.W_Offset-0x7F;
                      }
                      #endif
 129   3            }
 130   2            break;
 131   2          case RPD_6:
 132   2            {
 133   3              ClrBit(PI_LPF_CR, T2RPD); //??RPD
 134   3              DRV_CMR  = 0x00;
 135   3              RPD_Detect();
 136   3              RPD_Status=RPD_7;
 137   3            }
 138   2            break;
 139   2          default:
 140   2          {
 141   3              DRV_CMR  = 0x00;
 142   3          }
 143   2            break;
 144   2        }
 145   1      
 146   1      }
 147          /*---------------------------------------------------------------------------*/
 148          /* Name   : int16 RPD_Detect(int16 value)
 149          /* Input  : value
 150          /* Output : int16
 151          /* Description:RPD判断角度的方法
 152          /*---------------------------------------------------------------------------*/
 153          
 154          void RPD_Detect(void)
 155          {
 156   1        uint8 i,j;
 157   1        RPDPara.DetectCount[6]=RPDPara.DetectCount[0];
 158   1        for(i=0;i<5;i++)
 159   1        {
 160   2          if(RPDPara.DetectCount[6]>RPDPara.DetectCount[i+1])
 161   2          {
 162   3            RPDPara.injectmin=i+1;
 163   3            RPDPara.DetectCount[6]=RPDPara.DetectCount[i+1];
 164   3          }
 165   2        }
 166   1      
 167   1        RPDPara.DetectCount[RPDPara.injectmin]=65530;
 168   1      
 169   1        RPDPara.DetectCount[7]=RPDPara.DetectCount[0];
 170   1      
 171   1        for(j=0;j<5;j++)
 172   1        {
 173   2          if(RPDPara.DetectCount[7]>RPDPara.DetectCount[j+1])
 174   2          {
 175   3            RPDPara.injectmid=j+1;
 176   3            RPDPara.DetectCount[7]=RPDPara.DetectCount[j+1];
 177   3          }
C51 COMPILER V9.52.0.0   FU68XX_2_OTHER                                                    08/29/2018 19:34:24 PAGE 4   

 178   2        }
 179   1        switch(RPDPara.injectmin)
 180   1        {
 181   2          case 0:
 182   2              if(RPDPara.injectmid == 3)
 183   2                RPDPara.ThetaGet = 210;
 184   2              else
 185   2                RPDPara.ThetaGet = 180;
 186   2              break;
 187   2          case 1:
 188   2              if(RPDPara.injectmid == 2)
 189   2                RPDPara.ThetaGet = 30;
 190   2              else
 191   2                RPDPara.ThetaGet = 0;
 192   2              break;
 193   2          case 2:
 194   2              if(RPDPara.injectmid == 5)
 195   2                RPDPara.ThetaGet = 90;
 196   2              else
 197   2                RPDPara.ThetaGet = 60;
 198   2              break;
 199   2          case 3:
 200   2              if(RPDPara.injectmid == 4)
 201   2                RPDPara.ThetaGet = 270;
 202   2              else
 203   2                RPDPara.ThetaGet = 240;
 204   2              break;
 205   2          case 4:
 206   2              if(RPDPara.injectmid == 1)
 207   2                RPDPara.ThetaGet = 330;
 208   2              else
 209   2                RPDPara.ThetaGet = 300;
 210   2              break;
 211   2          case 5:
 212   2              if(RPDPara.injectmid == 0)
 213   2                RPDPara.ThetaGet = 150;
 214   2              else
 215   2                RPDPara.ThetaGet = 120;
 216   2              break;
 217   2          default:
 218   2              break;
 219   2        }
 220   1      }
 221          
 222          /*---------------------------------------------------------------------------*/
 223          /* Name   : void RSDCloseDeal(void)
 224          /* Input  : NO
 225          /* Output : NO
 226          /* Description: 
 227          /*---------------------------------------------------------------------------*/
 228          void RSDCloseDeal(void)
 229          {
 230   1          if((ReadBit(CMP_SR, CMP0OUT)==1)&&(ReadBit(CMP_SR, CMP1OUT)==0))
 231   1          {  
 232   2           #if (EstimateAlgorithm==PLL)  
                    {
                      FOC__ETHETA =5461;
                    }
                   #else
 237   2            {
 238   3              FOC__ETHETA=5461-4836;
 239   3              
C51 COMPILER V9.52.0.0   FU68XX_2_OTHER                                                    08/29/2018 19:34:24 PAGE 5   

 240   3            }
 241   2           #endif
 242   2          }
 243   1          else if((ReadBit(CMP_SR, CMP0OUT)==1)&&(ReadBit(CMP_SR, CMP1OUT)==1))
 244   1          {       
 245   2            #if (EstimateAlgorithm==PLL)  
                    {
                      FOC__ETHETA =16384;
                    }
                    #else
 250   2            {
 251   3              FOC__ETHETA=16384-4836;
 252   3            }
 253   2           #endif
 254   2            
 255   2          }
 256   1          else if((ReadBit(CMP_SR, CMP0OUT)==0)&&(ReadBit(CMP_SR, CMP1OUT)==1))
 257   1          {
 258   2            #if (EstimateAlgorithm==PLL)  
                     {
                      FOC__ETHETA =38229;
                     }
                    #else
 263   2             {
 264   3              FOC__ETHETA=38229-4836;
 265   3             }
 266   2            #endif
 267   2          }
 268   1          else
 269   1          {
 270   2            #if (EstimateAlgorithm==PLL)  
                    {
                     FOC__ETHETA  =49152;
                    }
                    #else
 275   2            {
 276   3              FOC__ETHETA=49152-4836;
 277   3            }
 278   2           #endif
 279   2          }
 280   1        
 281   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    809    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   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)
