T_TXPCL_RenesasPF09016B.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:21k
源码类别:

MTK

开发平台:

C++ Builder

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *   T_TXPCL_RenesasPF08151B.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui META APP
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  Renesas PF09016B TX PCL source
  48.  *
  49.  * Author:
  50.  * -------
  51.  *  Andy Ueng (mtk00490)
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * $Revision$
  58.  * $Modtime$
  59.  * $Log$
  60.  *
  61.  *------------------------------------------------------------------------------
  62.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  63.  *============================================================================
  64. ****************************************************************************/
  65. #include <assert.h>
  66. #include <math.h>
  67. #pragma hdrstop
  68. #ifndef _T_META_FACTORY_CALIBRATION_H_
  69. #include "T_META_factory_calibration.H"
  70. #endif
  71. #ifndef _CAL_COMMON_H_
  72. #include "cal_common.h"
  73. #endif
  74. #ifndef _APCCAL_COMMON_H_
  75. #include "apccal_common.h"
  76. #endif
  77. #ifndef  _RF_APC_H_
  78. #include "rf_apc.h"
  79. #endif
  80. // callback
  81. #ifndef _META_FACTORY_RF_CB_H_
  82. #include "meta_factory_rf_cb.h"
  83. #endif
  84. #ifndef _META_FACTORY_NVRAM_CB_H_
  85. #include "meta_factory_nvram_cb.h"
  86. #endif
  87. // form
  88. #ifndef _META_FACTORY_H_
  89. #include "META_Factory.h"
  90. #endif
  91. // equipment
  92. #ifndef  _AGE_MISC_H_
  93. #include "age_misc.h"
  94. #endif
  95. // misc
  96. #ifndef  _FT_UTILS_H_
  97. #include "ft_utils.h"
  98. #endif
  99. #ifndef  _BAND_UTILS_H_
  100. #include "band_utils.h"
  101. #endif
  102. #ifndef  _TIME_UTILS_H_
  103. #include "time_utils.h"
  104. #endif
  105. static const double RENESAS_PF08151B_CONST               = 3.1303;
  106. static const double RENESAS_PF08151B_GSM850_SWITCH_LOSS  = 1.2;
  107. static const double RENESAS_PF08151B_GSM_SWITCH_LOSS     = 1.2;
  108. static const double RENESAS_PF08151B_DCS1800_SWITCH_LOSS = 1.3;
  109. static const double RENESAS_PF08151B_PCS1900_SWITCH_LOSS = 1.3;
  110. //----------------------------------------------------------------------------
  111. extern CRFAPC*  MF_rf_apc_ptr;
  112. extern RfNbtx_Req *MF_rf_tx_level_req;
  113. extern bool MF_rf_tx_level_cnf;
  114. extern bool  is_suspend_cal; // in T_META_factory_calibration.cpp
  115. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  116. /////////////////////////////     Renesas PF08151B     ///////////////////////
  117. //---------------------------------------------------------------------------
  118. bool __fastcall T_META_factory_calibration::TXPCLCal_EvalDac_RenesasPF09016B( void )
  119. {
  120.      AnsiString  as_tx_pcl;
  121.      AnsiString  as_tx_cal_pcl;
  122.      AnsiString  as_wanted_p;
  123.      AnsiString  as_correction;
  124.      AnsiString  as_sub_tx_cal_pcl;
  125.      AnsiString  as_sub_tx_pcl;
  126.      AnsiString  as_sub_wanted_p;
  127.      AnsiString  as_sub_correction;
  128.      // Evaluate a and b
  129.      double   switch_loss;
  130.      unsigned short weight;
  131.      double d_weight;
  132.      unsigned short ramp_value;
  133.      unsigned short battery_compensate;
  134.      double  d_battery_compensate;
  135.      double  al, ah, bl, bh;
  136.      unsigned short i_PCL_Cal[MAX_SUPPORT_BAND_NUM][RF_TX_LEVEL_3_CAL_COUNT];
  137.      unsigned short EffPCLDac_Cal[MAX_SUPPORT_BAND_NUM][RF_TX_LEVEL_3_CAL_COUNT];
  138.     // double PoutV_Cal[MAX_SUPPORT_BAND_NUM][RF_TX_LEVEL_3_CAL_COUNT];
  139.      double Vout_Cal[MAX_SUPPORT_BAND_NUM][RF_TX_LEVEL_3_CAL_COUNT];
  140.      double Vramp_Cal[MAX_SUPPORT_BAND_NUM][RF_TX_LEVEL_3_CAL_COUNT];
  141.      double PoutV_Eval[MAX_SUPPORT_BAND_NUM][RF_RAMP_TABLE_TX_LEVEL_COUNT];
  142.      double Vramp_Eval[MAX_SUPPORT_BAND_NUM][RF_RAMP_TABLE_TX_LEVEL_COUNT];
  143.      unsigned short EffPclDac_Eval[MAX_SUPPORT_BAND_NUM][RF_RAMP_TABLE_TX_LEVEL_COUNT];
  144.     log->Add( "n" +DateToStr(Date()) +  " " + CurrentTimeStr() +
  145.                   " =================== Evaluate PCL DAC value begin =================== "
  146.                 );
  147.     short s_ARFCN;
  148.     int FIRST_PCL=0;
  149.     //int LAST_PCL=0;
  150.     FrequencyBand eFreqBand = FrequencyBand850;
  151.     E_BANDSEL band_index;
  152.     while (eFreqBand < FrequencyBandCount)
  153.     {
  154.         switch (eFreqBand)
  155.         {
  156.             case FrequencyBand850:
  157.             {
  158.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  159.                 {
  160.                     eFreqBand++;
  161.                     continue;
  162.                 }
  163.                 s_ARFCN        = m_sARFCN_C0_GSM850;
  164.                 band_index     = BANDSEL_GSM850;
  165.                 FIRST_PCL      = GSM850_FIRST_PCL;
  166.                 as_tx_pcl      = m_as_gsm850_tx_pcl;
  167.                 as_tx_cal_pcl  = m_as_gsm850_tx_cal_pcl;
  168.                 as_wanted_p    = m_as_gsm850_wanted_p;
  169.                 as_correction  = m_as_gsm850_correction;
  170.                 switch_loss    = RENESAS_PF08151B_GSM850_SWITCH_LOSS;
  171.             }
  172.             break;
  173.             case FrequencyBand900:
  174.             {
  175.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  176.                 {
  177.                     eFreqBand++;
  178.                     continue;
  179.                 }
  180.                 s_ARFCN        = m_sARFCN_C0_GSM;
  181.                 band_index     = BANDSEL_GSM900;
  182.                 FIRST_PCL      = GSM900_FIRST_PCL;
  183.                 as_tx_pcl      = m_as_gsm900_tx_pcl;
  184.                 as_tx_cal_pcl  = m_as_gsm900_tx_cal_pcl;
  185.                 as_wanted_p    = m_as_gsm900_wanted_p;
  186.                 as_correction  = m_as_gsm900_correction;
  187.                 switch_loss    = RENESAS_PF08151B_GSM_SWITCH_LOSS;
  188.             }
  189.             break;
  190.             case FrequencyBand1800:
  191.             {
  192.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  193.                 {
  194.                     eFreqBand++;
  195.                     continue;
  196.                 }
  197.                 s_ARFCN        = m_sARFCN_C0_DCS;
  198.                 band_index     = BANDSEL_DCS1800;
  199.                 FIRST_PCL      = DCS1800_FIRST_PCL;
  200.                 as_tx_pcl      = m_as_dcs1800_tx_pcl;
  201.                 as_tx_cal_pcl  = m_as_dcs1800_tx_cal_pcl;
  202.                 as_wanted_p    = m_as_dcs1800_wanted_p;
  203.                 as_correction  = m_as_dcs1800_correction;
  204.                 switch_loss    = RENESAS_PF08151B_DCS1800_SWITCH_LOSS;
  205.             }
  206.             break;
  207.             case FrequencyBand1900:
  208.             {
  209.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  210.                 {
  211.                     eFreqBand++;
  212.                     continue;
  213.                 }
  214.                 s_ARFCN        = m_sARFCN_C0_PCS;
  215.                 band_index     = BANDSEL_PCS1900;
  216.                 FIRST_PCL      = PCS1900_FIRST_PCL;
  217.                 as_tx_pcl      = m_as_pcs1900_tx_pcl;
  218.                 as_tx_cal_pcl  = m_as_pcs1900_tx_cal_pcl;
  219.                 as_wanted_p    = m_as_pcs1900_wanted_p;
  220.                 as_correction  = m_as_pcs1900_correction;
  221.                 switch_loss    = RENESAS_PF08151B_PCS1900_SWITCH_LOSS;
  222.             }
  223.             break;
  224.             default:
  225.                 assert(false);
  226.             break;
  227.         } // switch
  228.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() + " " +
  229.                               "---------------------------------------------"
  230.                         );
  231.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() + " " +
  232.                               BandIdx_To_String(band_index)
  233.                         );
  234.         int i;
  235.         for(i=0; i<RF_TX_LEVEL_3_CAL_COUNT; i++)
  236.         {
  237.            // PoutV_Cal[band_index][i] = sqrt(50.0*pow(10, (m_dPCL_dBm[band_index][i]+switch_loss)/10.0)/1000.0);
  238.            // log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  239.            //                " PoutV_Cal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  240.            //                  Double_To_AnsiString(PoutV_Cal[band_index][i]) + "n"
  241.            //             );
  242.             if (! getAnsiStrSubItem( as_tx_cal_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_cal_pcl) )
  243.             {
  244.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  245.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  246.                               " FAIL: Read config file fail(sub_tx_cal_pcl)."
  247.                         );
  248.                 return false;
  249.             }
  250.             i_PCL_Cal[band_index][i] = as_sub_tx_cal_pcl.ToInt();
  251.             l1cal_rampTable_T* p_ramp_table = MF_rf_apc_ptr->Get_ApcProfile(band_index);
  252.             if(! MF_rf_apc_ptr->Get_SubBandWeighting( *p_ramp_table, s_ARFCN, as_sub_tx_cal_pcl.ToInt(), weight) )
  253.             {
  254.                 CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  255.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  256.                               " FAIL: get sub-band weighting."
  257.                         );
  258.                 return false;
  259.             }
  260.             d_weight = 1.0 * weight / WEIGHT_SCALE;
  261.             if(! MF_rf_apc_ptr->Get_RightTopRampUpValue(*p_ramp_table, band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt(), ramp_value) )
  262.             {
  263.                 CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  264.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  265.                               " FAIL: get ramp up value."
  266.                         );
  267.                 return false;
  268.             }
  269.             if(! MF_rf_apc_ptr->Get_BatteryCompensate(*p_ramp_table, MID_VOLTAGE_INDEX, MID_TEMPERATURE_INDEX, battery_compensate) )
  270.             {
  271.                 CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  272.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  273.                               " FAIL: get battery_compensate value."
  274.                         );
  275.                 return false;
  276.             }
  277.             d_battery_compensate = 1.0* battery_compensate / BATTERY_COMPENSATE_SCALE;
  278.             EffPCLDac_Cal[band_index][i] = m_usPCLDacValue[band_index][i] * d_weight * d_battery_compensate * ramp_value / MAX_RAMP_VALUE;
  279.            // Vramp_Cal[band_index][i] = (MF_rf_apc_ptr->ApcDcOffset[band_index]+EffPCLDac_Cal[band_index][i])/pow(2.0, 10.0) * 2.8;
  280.            // Vramp_Cal[band_index][i] = (MF_rf_apc_ptr->Get_HighApcDcOffset(band_index)+EffPCLDac_Cal[band_index][i])/pow(2.0, 10.0) * 2.8;
  281.             if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, i_PCL_Cal[band_index][i], m_iApcDcOffset))
  282.             {
  283.                 CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
  284.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  285.                               " FAIL: Get APC DC offset " +
  286.                               " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
  287.                               " eFreqBand = " + IntToStr( eFreqBand ) +
  288.                               " pcl = " + IntToStr( i_PCL_Cal[band_index][i] )
  289.                         );
  290.                 return false;
  291.             }
  292.             Vramp_Cal[band_index][i] = (m_iApcDcOffset+EffPCLDac_Cal[band_index][i])/pow(2.0, 10.0) * 2.8;
  293.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  294.                            " Vramp_Cal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  295.                              Double_To_AnsiString(Vramp_Cal[band_index][i]) + "n"
  296.                         );
  297.             Vout_Cal[band_index][i] = sqrt( 50.0 * pow(10.0, (m_dPCL_dBm[band_index][i]+switch_loss)/10.0 ) );
  298.         }
  299.         al = ( Vout_Cal[band_index][1] - Vout_Cal[band_index][0] )/(Vramp_Cal[band_index][1]-Vramp_Cal[band_index][0]);
  300.         bl = Vout_Cal[band_index][0] - al*Vramp_Cal[band_index][0];
  301.         ah = ( Vout_Cal[band_index][2] - Vout_Cal[band_index][1] )/(Vramp_Cal[band_index][2]-Vramp_Cal[band_index][1]);
  302.         bh = Vout_Cal[band_index][1] - ah*Vramp_Cal[band_index][1];
  303.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  304.                               " Evaluate: al = " + Double_To_AnsiString(al) +
  305.                               ", bl = " + Double_To_AnsiString(bl) +
  306.                               ", ah = " + Double_To_AnsiString(ah) +
  307.                               ", bh = " + Double_To_AnsiString(bh)
  308.                         );
  309.         // Evaluate DAC except highest and lowest PCL
  310.         for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
  311.         {
  312.             if( i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
  313.                 (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
  314.               )
  315.             {
  316.                 break;
  317.             }
  318.             if (! getAnsiStrSubItem( as_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl) )
  319.             {
  320.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  321.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  322.                               " FAIL: Read config file fail(sub_tx_pcl)."
  323.                         );
  324.                 return false;
  325.             }
  326.             if (! getAnsiStrSubItem( as_wanted_p, i+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
  327.             {
  328.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  329.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  330.                               " FAIL: Read config file fail(sub_wanted_p)."
  331.                             );
  332.                 return false;
  333.             }
  334.             if (! getAnsiStrSubItem( as_correction, i+1, DEFAULT_SEP_CHAR, as_sub_correction) )
  335.             {
  336.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  337.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  338.                               " FAIL: Read config file fail(as_sub_correction)."
  339.                             );
  340.                 return false;
  341.             }
  342.             if( as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_LOW_INDEX] &&
  343.                 as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_MID_INDEX] &&
  344.                 as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_HIGH_INDEX]
  345.               )
  346.             {
  347.                 PoutV_Eval[band_index][i] = sqrt( 50*pow(10.0, (switch_loss + atof(as_sub_wanted_p.c_str()) + atof(as_sub_correction.c_str()))/10.0 )/1000.0 );
  348.                 if( as_sub_tx_pcl.ToInt() > i_PCL_Cal[band_index][PCL_MID_INDEX] )
  349.                 {
  350.                      Vramp_Eval[band_index][i] = (PoutV_Eval[band_index][i] - bl)/al;
  351.                 }
  352.                 else
  353.                 {
  354.                     Vramp_Eval[band_index][i] = (PoutV_Eval[band_index][i] - bh)/ah;;
  355.                 }
  356.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  357.                            " PoutV_Eval[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  358.                              Double_To_AnsiString(PoutV_Eval[band_index][i]) + "n"
  359.                         );
  360.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  361.                            " Vramp_Eval[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  362.                              Double_To_AnsiString(Vramp_Eval[band_index][i]) + "n"
  363.                         );
  364.                
  365.                // EffPclDac_Eval[band_index][i] = (Vramp_Eval[band_index][i]*pow(2.0,10.0))/2.8 - MF_rf_apc_ptr->ApcDcOffset[band_index];
  366.                // EffPclDac_Eval[band_index][i] = (Vramp_Eval[band_index][i]*pow(2.0,10.0))/2.8 - MF_rf_apc_ptr->Get_HighApcDcOffset(band_index);
  367.                 if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_sub_tx_pcl.ToInt(), m_iApcDcOffset ) )
  368.                 {
  369.                     CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
  370.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  371.                               " FAIL: Get APC DC offset " +
  372.                               " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
  373.                               " eFreqBand = " + IntToStr( eFreqBand ) +
  374.                               " pcl = " + IntToStr( i_PCL_Cal[band_index][i] )
  375.                         );
  376.                     return false;
  377.                 }
  378.                 EffPclDac_Eval[band_index][i] = (Vramp_Eval[band_index][i]*pow(2.0,10.0))/2.8 - m_iApcDcOffset;
  379.                 if( d_weight*d_battery_compensate*ramp_value == 0 )
  380.                 {
  381.                     CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  382.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  383.                               " FAIL: weight*battery_compensate*ramp_value = 0."
  384.                         );
  385.                     return false;
  386.                 }
  387.                 m_usPCLDacValue_ideal[band_index][i] = EffPclDac_Eval[band_index][i]*MAX_RAMP_VALUE/(d_weight*d_battery_compensate*ramp_value);
  388.                // MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[i] = m_usPCLDacValue_ideal[band_index][i];
  389.                 MF_rf_apc_ptr->Set_ApcProfilePower(band_index, i, m_usPCLDacValue_ideal[band_index][i]);
  390.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  391.                           // "                         " +
  392.                            " m_usPCLDacValue_ideal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  393.                              Double_To_AnsiString(m_usPCLDacValue_ideal[band_index][i]) + "n"
  394.                         );
  395.             }
  396.         }
  397.         MF_rf_apc_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
  398.         MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, m_pCal->b_TADOSupport );
  399.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  400.                       " Write to NVRAM band_index = " + IntToStr(band_index)
  401.                     );
  402.         //log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  403.         //             " TimerCal->Enabled 15= " + IntToStr((int)frmFatcory->TimerCal->Enabled) + "n"
  404.         //           );
  405.         RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  406.         CHECK_TERMINATE_BY_USER
  407.         SUSPEND_CAL_THREAD
  408.         E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
  409.         if (state != METAAPP_SUCCESS)
  410.         {
  411.             if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
  412.             {
  413.                 CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
  414.                 log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  415.                              " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
  416.                              );
  417.             }
  418.             else
  419.             {
  420.                 CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  421.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  422.                                       " FAIL: Target < write APC to NVRAM "
  423.                                     );
  424.             }
  425.             return false;
  426.         }
  427.         WriteAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
  428.         eFreqBand++;
  429.     } // while
  430.     
  431.     frmFatcory->DisableAllCalTimer();
  432.     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  433.                  " ===================== Evaluate other PCL DAC value end =========== n "
  434.                 );
  435.     return true;
  436. }