T_TXPCL_RenesasPF08155B.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_RenesasPF08155B.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui META APP
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  Renesas PF08151B 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 PF08155B     ///////////////////////
  117. //---------------------------------------------------------------------------
  118. bool __fastcall T_META_factory_calibration::TXPCLCal_EvalDac_RenesasPF08155B( 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_pcl;
  125.      AnsiString  as_sub_tx_cal_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 Vramp_Cal[MAX_SUPPORT_BAND_NUM][RF_TX_LEVEL_3_CAL_COUNT];
  140.      double PoutV_Eval[MAX_SUPPORT_BAND_NUM][RF_RAMP_TABLE_TX_LEVEL_COUNT];
  141.      double Vramp_Eval[MAX_SUPPORT_BAND_NUM][RF_RAMP_TABLE_TX_LEVEL_COUNT];
  142.      unsigned short EffPclDac_Eval[MAX_SUPPORT_BAND_NUM][RF_RAMP_TABLE_TX_LEVEL_COUNT];
  143.     log->Add( "n" +DateToStr(Date()) +  " " + CurrentTimeStr() +
  144.                   " =================== Evaluate PCL DAC value begin =================== "
  145.                 );
  146.     int FIRST_PCL=0;
  147.     short s_ARFCN;
  148.     E_BANDSEL band_index;
  149.     FrequencyBand eFreqBand = FrequencyBand850;
  150.     while (eFreqBand < FrequencyBandCount)
  151.     {
  152.         switch (eFreqBand)
  153.         {
  154.             case FrequencyBand850:
  155.             {
  156.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  157.                 {
  158.                     eFreqBand++;
  159.                     continue;
  160.                 }
  161.                 s_ARFCN        = m_sARFCN_C0_GSM850;
  162.                 band_index     = BANDSEL_GSM850;
  163.                 FIRST_PCL      = GSM850_FIRST_PCL;
  164.                 as_tx_pcl      = m_as_gsm850_tx_pcl;
  165.                 as_tx_cal_pcl  = m_as_gsm850_tx_cal_pcl;
  166.                 as_wanted_p    = m_as_gsm850_wanted_p;
  167.                 as_correction  = m_as_gsm850_correction;
  168.                 switch_loss    = RENESAS_PF08151B_GSM850_SWITCH_LOSS;
  169.             }
  170.             break;
  171.             case FrequencyBand900:
  172.             {
  173.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  174.                 {
  175.                     eFreqBand++;
  176.                     continue;
  177.                 }
  178.                 s_ARFCN        = m_sARFCN_C0_GSM;
  179.                 band_index     = BANDSEL_GSM900;
  180.                 FIRST_PCL      = GSM900_FIRST_PCL;
  181.                 as_tx_pcl      = m_as_gsm900_tx_pcl;
  182.                 as_tx_cal_pcl  = m_as_gsm900_tx_cal_pcl;
  183.                 as_wanted_p    = m_as_gsm900_wanted_p;
  184.                 as_correction  = m_as_gsm900_correction;
  185.                 switch_loss    = RENESAS_PF08151B_GSM_SWITCH_LOSS;
  186.             }
  187.             break;
  188.             case FrequencyBand1800:
  189.             {
  190.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  191.                 {
  192.                     eFreqBand++;
  193.                     continue;
  194.                 }
  195.                 s_ARFCN        = m_sARFCN_C0_DCS;
  196.                 band_index     = BANDSEL_DCS1800;
  197.                 FIRST_PCL      = DCS1800_FIRST_PCL;
  198.                 as_tx_pcl      = m_as_dcs1800_tx_pcl;
  199.                 as_tx_cal_pcl  = m_as_dcs1800_tx_cal_pcl;
  200.                 as_wanted_p    = m_as_dcs1800_wanted_p;
  201.                 as_correction  = m_as_dcs1800_correction;
  202.                 switch_loss    = RENESAS_PF08151B_DCS1800_SWITCH_LOSS;
  203.             }
  204.             break;
  205.             case FrequencyBand1900:
  206.             {
  207.                 if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
  208.                 {
  209.                     eFreqBand++;
  210.                     continue;
  211.                 }
  212.                 s_ARFCN        = m_sARFCN_C0_PCS;
  213.                 band_index     = BANDSEL_PCS1900;
  214.                 FIRST_PCL      = PCS1900_FIRST_PCL;
  215.                 as_tx_pcl      = m_as_pcs1900_tx_pcl;
  216.                 as_tx_cal_pcl  = m_as_pcs1900_tx_cal_pcl;
  217.                 as_wanted_p    = m_as_pcs1900_wanted_p;
  218.                 as_correction  = m_as_pcs1900_correction;
  219.                 switch_loss    = RENESAS_PF08151B_PCS1900_SWITCH_LOSS;
  220.             }
  221.             break;
  222.             default:
  223.                 assert(false);
  224.             break;
  225.         } // switch
  226.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() + " " +
  227.                               "---------------------------------------------"
  228.                         );
  229.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() + " " +
  230.                               BandIdx_To_String(band_index)
  231.                         );
  232.         int i=0;
  233.         for(i=0; i<RF_TX_LEVEL_3_CAL_COUNT; i++)
  234.         {
  235.             PoutV_Cal[band_index][i] = sqrt(50.0*pow(10, (m_dPCL_dBm[band_index][i]+switch_loss)/10.0)/1000.0);
  236.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  237.                            " PoutV_Cal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  238.                              Double_To_AnsiString(PoutV_Cal[band_index][i]) + "n"
  239.                         );
  240.             if (! getAnsiStrSubItem( as_tx_cal_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_cal_pcl) )
  241.             {
  242.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  243.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  244.                               " FAIL: Read config file fail(sub_tx_cal_pcl)."
  245.                         );
  246.                 return false;
  247.             }
  248.             i_PCL_Cal[band_index][i] = as_sub_tx_cal_pcl.ToInt();
  249.             l1cal_rampTable_T* p_ramp_table = MF_rf_apc_ptr->Get_ApcProfile(band_index);
  250.             if(! MF_rf_apc_ptr->Get_SubBandWeighting(*p_ramp_table, s_ARFCN, as_sub_tx_cal_pcl.ToInt(), weight) )
  251.             {
  252.                 CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  253.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  254.                               " FAIL: get sub-band weighting."
  255.                         );
  256.                 return false;
  257.             }
  258.             d_weight = 1.0 * weight / WEIGHT_SCALE;
  259.             if(! MF_rf_apc_ptr->Get_RightTopRampUpValue(*p_ramp_table, band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt(), ramp_value) )
  260.             {
  261.                 CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  262.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  263.                               " FAIL: get ramp up value."
  264.                         );
  265.                 return false;
  266.             }
  267.             if(! MF_rf_apc_ptr->Get_BatteryCompensate(*p_ramp_table, MID_VOLTAGE_INDEX, MID_TEMPERATURE_INDEX, battery_compensate) )
  268.             {
  269.                 CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  270.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  271.                               " FAIL: get battery_compensate value."
  272.                         );
  273.                 return false;
  274.             }
  275.             d_battery_compensate = 1.0* battery_compensate / BATTERY_COMPENSATE_SCALE;
  276.             EffPCLDac_Cal[band_index][i] = m_usPCLDacValue[band_index][i] * d_weight * d_battery_compensate * ramp_value / MAX_RAMP_VALUE;
  277.             //    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;
  278.             if( ! MF_rf_apc_ptr->Get_RealApcDcOffset(m_pCal->b_TADOSupport, band_index, i_PCL_Cal[band_index][i], m_iApcDcOffset ) )
  279.             {
  280.                 CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  281.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  282.                               " FAIL: PCL to dBm " +
  283.                               " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
  284.                               " eFreqBand = " + IntToStr( eFreqBand ) +
  285.                               " pcl = " + IntToStr( i_PCL_Cal[band_index][i] )
  286.                         );
  287.                 return false;
  288.             }
  289.             Vramp_Cal[band_index][i] = (m_iApcDcOffset+EffPCLDac_Cal[band_index][i])/pow(2.0, 10.0) * 2.8;
  290.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  291.                            " Vramp_Cal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  292.                              Double_To_AnsiString(Vramp_Cal[band_index][i]) + "n"
  293.                         );
  294.         }
  295.         al = ( PoutV_Cal[band_index][1] - PoutV_Cal[band_index][0] - RENESAS_PF08151B_CONST * (pow(Vramp_Cal[band_index][1], 2.0)-pow(Vramp_Cal[band_index][0], 2.0)) )/(2*RENESAS_PF08151B_CONST *(Vramp_Cal[band_index][1]-Vramp_Cal[band_index][0]));
  296.         bl = PoutV_Cal[band_index][0]-RENESAS_PF08151B_CONST*pow(Vramp_Cal[band_index][0]+al,2.0);
  297.         ah = ( PoutV_Cal[band_index][2] - PoutV_Cal[band_index][1] - RENESAS_PF08151B_CONST * (pow(Vramp_Cal[band_index][2], 2.0)-pow(Vramp_Cal[band_index][1], 2.0)) )/(2*RENESAS_PF08151B_CONST *(Vramp_Cal[band_index][2]-Vramp_Cal[band_index][1]));
  298.         bh = PoutV_Cal[band_index][2]-RENESAS_PF08151B_CONST*pow(Vramp_Cal[band_index][2]+ah,2.0);
  299.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  300.                               " Evaluate: al = " + Double_To_AnsiString(al) +
  301.                               ", bl = " + Double_To_AnsiString(bl) +
  302.                               ", ah = " + Double_To_AnsiString(ah) +
  303.                               ", bh = " + Double_To_AnsiString(bh)
  304.                         );
  305.         // Evaluate DAC except highest and lowest PCL
  306.         for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
  307.         {
  308.             if( i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
  309.                 (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
  310.               )
  311.             {
  312.                 break;
  313.             }
  314.             if (! getAnsiStrSubItem( as_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl) )
  315.             {
  316.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  317.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  318.                               " FAIL: Read config file fail(sub_tx_pcl)."
  319.                         );
  320.                 return false;
  321.             }
  322.             if (! getAnsiStrSubItem( as_wanted_p, i+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
  323.             {
  324.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  325.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  326.                               " FAIL: Read config file fail(sub_wanted_p)."
  327.                             );
  328.                 return false;
  329.             }
  330.             if (! getAnsiStrSubItem( as_correction, i+1, DEFAULT_SEP_CHAR, as_sub_correction) )
  331.             {
  332.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  333.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  334.                               " FAIL: Read config file fail(as_sub_correction)."
  335.                             );
  336.                 return false;
  337.             }
  338.             if( as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_LOW_INDEX] &&
  339.                 as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_MID_INDEX] &&
  340.                 as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_HIGH_INDEX]
  341.               )
  342.             {
  343.                 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 );
  344.                 if( as_sub_tx_pcl.ToInt() > i_PCL_Cal[band_index][PCL_MID_INDEX] )
  345.                 {
  346.                     Vramp_Eval[band_index][i] = sqrt((PoutV_Eval[band_index][i]-bl)/RENESAS_PF08151B_CONST) - al;
  347.                 }
  348.                 else
  349.                 {
  350.                     Vramp_Eval[band_index][i] = sqrt((PoutV_Eval[band_index][i]-bh)/RENESAS_PF08151B_CONST) - ah;
  351.                 }
  352.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  353.                            " PoutV_Eval[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  354.                              Double_To_AnsiString(PoutV_Eval[band_index][i]) + "n"
  355.                         );
  356.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  357.                            " Vramp_Eval[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  358.                              Double_To_AnsiString(Vramp_Eval[band_index][i]) + "n"
  359.                         );
  360.                // 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);
  361.                 if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_sub_tx_pcl.ToInt(), m_iApcDcOffset ) )
  362.                 {
  363.                     CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  364.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  365.                               " FAIL: Get APC DC offset " +
  366.                               " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
  367.                               " eFreqBand = " + IntToStr( eFreqBand ) +
  368.                               " pcl = " + IntToStr( i_PCL_Cal[band_index][i] )
  369.                         );
  370.                     return false;
  371.                 }
  372.                 EffPclDac_Eval[band_index][i] = (Vramp_Eval[band_index][i]*pow(2.0,10.0))/2.8 - m_iApcDcOffset;
  373.                 
  374.                 if( d_weight*d_battery_compensate*ramp_value == 0 )
  375.                 {
  376.                     CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
  377.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  378.                               " FAIL: weight*battery_compensate*ramp_value = 0."
  379.                         );
  380.                     return false;
  381.                 }
  382.                 m_usPCLDacValue_ideal[band_index][i] = EffPclDac_Eval[band_index][i]*MAX_RAMP_VALUE/(d_weight*d_battery_compensate*ramp_value);
  383.                 MF_rf_apc_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal[band_index][i] );
  384.                // MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[i] = m_usPCLDacValue_ideal[band_index][i];
  385.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  386.                           // "                         " +
  387.                            " m_usPCLDacValue_ideal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  388.                              Double_To_AnsiString(m_usPCLDacValue_ideal[band_index][i]) + "n"
  389.                         );
  390.             }
  391.         }
  392.         MF_rf_apc_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
  393.         MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, m_pCal->b_TADOSupport );
  394.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  395.                       " Write to NVRAM band_index = " + IntToStr(band_index)
  396.                     );
  397.         //log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  398.         //             " TimerCal->Enabled 15= " + IntToStr((int)frmFatcory->TimerCal->Enabled) + "n"
  399.         //           );
  400.         RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  401.         CHECK_TERMINATE_BY_USER
  402.         SUSPEND_CAL_THREAD
  403.         E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
  404.         if (state != METAAPP_SUCCESS)
  405.         {
  406.             if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
  407.             {
  408.                 CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
  409.                 log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  410.                              " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
  411.                              );
  412.             }
  413.             else
  414.             {
  415.                 CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  416.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  417.                                       " FAIL: Target < write APC to NVRAM "
  418.                                     );
  419.             }
  420.             return false;
  421.         }
  422.         WriteAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
  423.         eFreqBand++;
  424.     } // while
  425.     frmFatcory->DisableAllCalTimer();
  426.   
  427.     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  428.                  " ===================== Evaluate other PCL DAC value end =========== n "
  429.                 );
  430.     return true;
  431. }