T_TxIq.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:58k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2001
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * T_TxIq.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * TX IQ calibration source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include <assert.h>
- #include <math.h>
- #pragma hdrstop
- #ifndef _T_TXIQ_COMMON_H_
- #include "T_TxIq_common.h"
- #endif
- #ifndef _CAL_COMMON_H_
- #include "cal_common.h"
- #endif
- // misc
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _MATH_UTILS_H_
- #include "math_utils.h"
- #endif
- #ifndef _AGE_MISC_H_
- #include "age_misc.h"
- #endif
- #ifndef _GSM_UTILS_H_
- #include "gsm_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- // equipment
- #ifndef _AGECOMMON_H_
- #include "agecommon.h"
- #endif
- #ifndef _AGE1968A_H_
- #include "age1968a.h"
- #endif
- // TX phase error calibration
- #ifndef _RF_OFFSET_IQ_SWEEP_INIT_AGE8960_H_
- #include "rf_offset_iq_sweep_init_age8960.h"
- #endif
- #ifndef _RF_TXIQ_H_
- #include "rf_txiq.h"
- #endif
- // form
- #ifndef _META_FACTORY_H_
- #include "META_Factory.h"
- #endif
- // call back
- #ifndef _META_FACTORY_NVRAM_CB_H_
- #include "meta_factory_nvram_cb.h"
- #endif
- #ifndef _META_FACTORY_RF_CB_H_
- #include "meta_factory_rf_cb.h"
- #endif
- //----------------------------------------------------------------------------
- // phase error
- extern RfNbtx_Req *MF_rf_tx_level_req;
- extern CRFTXIQ* MF_rf_txiq_ptr;
- // Tthread
- extern T_META_factory_calibration* pt_calibration;
- extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
- //---------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::TXIqCal( void )
- {
- ViReal64 d_OOS[4];
- ViReal64 d_POOS[4];
- ViReal64 d_SBS[4];
- ViReal64 d_PSBS[4];
- RfBBTXCfg4 rf_bb_tx_cfg_req;
- BBTXParameters_T l1cal_txiq;
- S_IQ OffsetIQ[] =
- {
- { 0, 0},
- { 0, 30},
- { 30, -30},
- {-30, -30}
- };
- S_IQ TrimIQ[] =
- {
- { 0, 0},
- { 7, -7},
- { -7, 7},
- };
- S_IQ offset_IQt;
- S_IQ trim_IQt;
- S_IQ offset_IQt_h;
- S_IQ trim_IQt_h;
- double d_OOS_Check_h;
- double d_SBS_Check_h;
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_IQ_BEGIN,
- 0,
- 0
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================ TX IQ calibration begin ================== "
- );
- if (!m_rct_ctrl.RCT_operatingMode(m_pRct, OPERATING_MODE_GSM_BCH_TCH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_OPERATION_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :" +
- m_pRct->as_RCT + " < Operation mode = GSM BCH+TCH"
- );
- return false;
- }
- m_viTX_IQ_BAND = Get_AgeBand(m_asTX_IQ_BAND);
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, m_viTX_IQ_BAND))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(m_viTX_IQ_BAND)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < Band = "+
- ViBand_To_Str( m_viTX_IQ_BAND )
- );
- if (age1960_PCS1900_BAND == m_viTX_IQ_BAND)
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_AFC_SELECT_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 1"
- );
- return false;
- }
- }
- else
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_AFC_SELECT_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 0"
- );
- return false;
- }
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- short bch_arfcn = ::Get_SeperateChannel(m_viTX_IQ_BAND, m_sTX_IQ_ARFCN);
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, bch_arfcn))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(bch_arfcn)
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_TCHARFCN(m_pRct, m_sTX_IQ_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN)
- );
- if (!m_rct_ctrl.RCT_MSTXLevel(m_pRct, m_sTX_IQ_PCL))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr( m_sTX_IQ_PCL )
- );
- if (!m_rct_ctrl.RCT_ConfigTSC(m_pRct, m_cTSC))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TSC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL : " + m_pRct->as_RCT + " set TSC fail."
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if (!m_rct_ctrl.RCT_confIQTuning(m_pRct, m_uiTX_IQ_MEASUREMENT_COUNT))
- {
- CalErrorHandler(WM_MF_AGE8960_CONFIG_IQ_TUNNING_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL : " + m_pRct->as_RCT + " < config IQ tunning fail."
- );
- return false;
- }
- // BB TX auto calibration
- // if( META_Rf_BBTXAutoCal_r( 1500 ) != META_SUCCESS )
- // {
- // CalErrorHandler( WM_MF_RF_TX_GAIN_AUTO_CAL_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: RF TX gain auto calibration."
- // );
- // return false;
- // }
- // get BBTxCfg
- //if (META_Rf_GetBBTxCfg2_r(m_pCal->i_MainMETAHandle, 1500, &rf_bb_tx_cfg_req) != META_SUCCESS )
- //{
- // CalErrorHandler( WM_MF_RF_GET_BB_TX_CFG_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: RF get BB TX CFG fail."
- // );
- // return false;
- //}
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_GetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver);
- RestartTimerCal(WM_MF_RF_GET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_GET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > RF get BB TX CFG fail."
- );
- return false;
- }
- RfBBTXCfg4* p_bbtx_cfg = m_cTXIQ_RUN_Obj.Get_BbTxCfg();
- rf_bb_tx_cfg_req = *p_bbtx_cfg;
- // read TXIQ from NVRAM
- MF_rf_txiq_ptr->ConfirmCallback = ::ccb_read_txiq_from_nvram;
- MF_rf_txiq_ptr->REQ_Read_From_NVRAM_Start(m_pCal->ui_rf_id, m_pCal->e_bbtxcfg_ver);
- RestartTimerCal(WM_MF_NVRAM_TXIQ_READ_FAIL);
- SUSPEND_CAL_THREAD
- if (MF_rf_txiq_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_NVRAM_TXIQ_READ_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target > Read txiq value from NVRAM fail "
- );
- return false;
- }
- BBTXParameters_T* p_txiq = MF_rf_txiq_ptr->Get_BBTXParameters();
- l1cal_txiq = *p_txiq;
- // MF_rf_txiq_ptr->Set_BBTxParametersFromAutoK( &rf_bb_tx_cfg_req );
- // low band
- l1cal_txiq.bbtx_gain = rf_bb_tx_cfg_req.TxGain;
- l1cal_txiq.bbtx_calrcsel = rf_bb_tx_cfg_req.TxCalrcsel;
- l1cal_txiq.bbtx_common_mode_voltage = rf_bb_tx_cfg_req.TxCMV;
- // high band
- l1cal_txiq.bbtx_gain_h = rf_bb_tx_cfg_req.TxGain;
- l1cal_txiq.bbtx_calrcsel_h = rf_bb_tx_cfg_req.TxCalrcsel; // new
- l1cal_txiq.bbtx_common_mode_voltage_h = rf_bb_tx_cfg_req.TxCMV; // new
- // get OOS
- for (int i=0; i<4; i++)
- {
- if (i<=2)
- {
- rf_bb_tx_cfg_req.TxTrimI = TrimIQ[i].I;
- rf_bb_tx_cfg_req.TxTrimQ = TrimIQ[i].Q;
- }
- rf_bb_tx_cfg_req.TxOffsetI = OffsetIQ[i].I;
- rf_bb_tx_cfg_req.TxOffsetQ = OffsetIQ[i].Q;
- //if (META_Rf_SetBBTxCfg2_r(m_pCal->i_MainMETAHandle, 5000, &rf_bb_tx_cfg_req, &rf_bb_tx_cfg2_cnf) != META_SUCCESS )
- //{
- // CalErrorHandler( WM_MF_RF_SET_BB_TX_CFG_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " FAIL: RF set BB TX config fail."
- // );
- // return false;
- //}
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_RF_TX_IQ_FAIL);
- MF_rf_tx_level_req->arfcn = m_sTX_IQ_ARFCN;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = m_sTX_IQ_PCL;
- MF_rf_tx_level_req->frames = -99;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- if (frmFatcory->rbAgilent8960->Checked)
- {
- MF_rf_tx_level_req->burstTypeNB = NB_TX_ALL_ONES_WITHOUT_TSC;
- }
- else
- { MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC;
- }
- if (META_Rf_NB_TX_r(m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- ::ccb_MF_rf_tx_level_TrOff,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(m_sTX_IQ_ARFCN) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", power = " + m_sTX_IQ_PCL +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- return false;
- }
- SUSPEND_CAL_THREAD
- Sleep(100);
- // TX IQ gain imbalance & original offset
- // if( i<=2 )
- {
- if (!m_rct_ctrl.RCT_readTxIq(m_pRct, d_SBS[i], d_OOS[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_IQ_TUNNING_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > read TX IQ tunning fail."
- );
- return false;
- }
- if (i<=2)
- {
- if (NAN == d_SBS[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX IQ imbalance fail."
- );
- return false;
- }
- d_PSBS[i] = exp(d_SBS[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " TrimI = " + IntToStr( TrimIQ[i].I ) +
- ", TrimQ = " + IntToStr( TrimIQ[i].Q ) +
- ", SBS = " + Double_To_AnsiString( d_SBS[i] ) +
- ", PSBS = " + Double_To_AnsiString( d_PSBS[i] )
- );
- }
- }
- if (NAN == d_OOS[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX original offset fail."
- );
- return false;
- }
- d_POOS[i] = exp(d_OOS[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr(OffsetIQ[i].I) +
- ", OffsetQ = " + IntToStr(OffsetIQ[i].Q) +
- ", OOS = " + Double_To_AnsiString(d_OOS[i]) +
- ", POOS = " + Double_To_AnsiString(d_POOS[i])
- );
- Sleep(50);
- RestartTimerCal(WM_MF_RF_TX_IQ_FAIL);
- STOP_RF
- }
- // TX IQ gain imbalance
- ViReal64 Xt;
- Xt = 14*(d_PSBS[2]-d_PSBS[1]) / (2*(d_PSBS[2]+d_PSBS[1]-2*d_PSBS[0]));
- float fdata = Xt/2.0;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- trim_IQt.I = fdata;
- fdata = -1.0*(Xt - trim_IQt.I);
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- trim_IQt.Q = fdata;
- if (trim_IQt.I > MAX_TRIM_IQ)
- {
- trim_IQt.I = MAX_TRIM_IQ;
- }
- else if (trim_IQt.I < MIN_TRIM_IQ)
- {
- trim_IQt.I = MIN_TRIM_IQ;
- }
- if (trim_IQt.Q > MAX_TRIM_IQ)
- {
- trim_IQt.Q = MAX_TRIM_IQ;
- }
- else if (trim_IQt.Q < MIN_TRIM_IQ)
- {
- trim_IQt.Q = MIN_TRIM_IQ;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate Xt = " + Double_To_AnsiString(Xt) + ", TrimI = " + IntToStr( trim_IQt.I ) +
- ", TrimQ = " + IntToStr( trim_IQt.Q )
- );
- // TX DC offset
- fdata = 30*3*(d_POOS[3]-d_POOS[2]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0]));
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt.I = fdata;
- fdata= 30*(d_POOS[3]+d_POOS[2]-4*d_POOS[1]+2*d_POOS[0]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0]));
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt.Q = fdata;
- char MAX_OFFSET_IQ;
- char MIN_OFFSET_IQ;
- if (m_pCal->e_bbtxcfg_ver < BBTXCFG_VER4)
- {
- MIN_OFFSET_IQ = MIN_OFFSET_IQ_OLD;
- MAX_OFFSET_IQ = MAX_OFFSET_IQ_OLD;
- }
- else
- {
- MIN_OFFSET_IQ = MIN_OFFSET_IQ_NEW;
- MAX_OFFSET_IQ = MAX_OFFSET_IQ_NEW;
- }
- if (offset_IQt.I > MAX_OFFSET_IQ)
- {
- offset_IQt.I = MAX_OFFSET_IQ;
- }
- else if (offset_IQt.I < MIN_OFFSET_IQ)
- {
- offset_IQt.I = MIN_OFFSET_IQ;
- }
- if (offset_IQt.Q > MAX_OFFSET_IQ)
- {
- offset_IQt.Q = MAX_OFFSET_IQ;
- }
- else if (offset_IQt.Q < MIN_OFFSET_IQ)
- {
- offset_IQt.Q = MIN_OFFSET_IQ;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate OffsetI = " + IntToStr(offset_IQt.I) +
- ", OffsetQ = " + IntToStr(offset_IQt.Q)
- );
- l1cal_txiq.bbtx_trimI = trim_IQt.I;
- l1cal_txiq.bbtx_trimQ = trim_IQt.Q;
- l1cal_txiq.bbtx_offsetI = offset_IQt.I;
- l1cal_txiq.bbtx_offsetQ = offset_IQt.Q;
- rf_bb_tx_cfg_req.TxTrimI = trim_IQt.I;
- rf_bb_tx_cfg_req.TxTrimQ = trim_IQt.Q;
- rf_bb_tx_cfg_req.TxOffsetI = offset_IQt.I;
- rf_bb_tx_cfg_req.TxOffsetQ = offset_IQt.Q;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- #if 0
- // phase calibration
- if (m_pCal->e_bbtxcfg_ver >= BBTXCFG_VER3)
- {
- char TxPhasesel[2] = {0, 3};
- double d_SBS_phase[2];
- double d_PSBS_phase[2];
- char TxPhasesel_min;
- for (int i=0; i<2; i++)
- {
- rf_bb_tx_cfg_req.TxPhasesel = TxPhasesel[i];
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_RF_TX_IQ_FAIL);
- MF_rf_tx_level_req->arfcn = m_sTX_IQ_ARFCN;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = m_sTX_IQ_PCL;
- MF_rf_tx_level_req->frames = -99;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- if (frmFatcory->rbAgilent8960->Checked)
- {
- MF_rf_tx_level_req->burstTypeNB = NB_TX_ALL_ONES_WITHOUT_TSC;
- }
- else
- {
- MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC;
- }
- if (META_Rf_NB_TX_r(m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- ::ccb_MF_rf_tx_level_TrOff,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(m_sTX_IQ_ARFCN) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", power = " + m_sTX_IQ_PCL +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- return false;
- }
- SUSPEND_CAL_THREAD
- Sleep(100);
- if (!m_rct_ctrl.RCT_readTxIqImbalance(m_pRct, d_SBS_phase[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_IQ_TUNNING_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > read TX IQ tunning fail."
- );
- return false;
- }
- if (NAN == d_SBS_phase[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX IQ imbalance fail."
- );
- return false;
- }
- d_PSBS_phase[i] = exp(d_SBS_phase[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " TxPhasesel = " + IntToStr(TxPhasesel[i]) +
- ", SBS = " + Double_To_AnsiString(d_SBS_phase[i]) +
- ", PSBS = " + Double_To_AnsiString(d_PSBS_phase[i])
- );
- Sleep(50);
- RestartTimerCal(WM_MF_RF_TX_IQ_FAIL);
- STOP_RF
- }
- fdata = (TxPhasesel[1]*TxPhasesel[1] + 4*d_PSBS_phase[0] - 4*d_PSBS_phase[1])/(2*TxPhasesel[1]);
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- TxPhasesel_min = (char) fdata;
- if (TxPhasesel_min > MAX_PHASESEL)
- {
- TxPhasesel_min = MAX_PHASESEL;
- }
- else if (TxPhasesel_min < MIN_PHASESEL)
- {
- TxPhasesel_min = MIN_PHASESEL;
- }
- l1cal_txiq.bbtx_phsel = (unsigned char) TxPhasesel_min;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate TxPhasesel = " + IntToStr(TxPhasesel_min)
- );
- }
- #endif
- //------------------------------------------------------------------------
- // high band calibration
- if ((RF_ID_A60111A == m_pCal->ui_rf_id) ||
- (RF_ID_AERO2E == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140A == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140B == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140C == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140D == m_pCal->ui_rf_id)
- )
- {
- m_viTX_IQ_BAND_HIGH = Get_AgeBand(m_asTX_IQ_BAND_HIGH);
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, m_viTX_IQ_BAND_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(m_viTX_IQ_BAND_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < Band = "+
- ViBand_To_Str(m_viTX_IQ_BAND_HIGH)
- );
- if (age1960_PCS1900_BAND == m_viTX_IQ_BAND_HIGH)
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_AFC_SELECT_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 1"
- );
- return false;
- }
- }
- else
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_AFC_SELECT_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 0"
- );
- return false;
- }
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- short bch_arfcn = ::Get_SeperateChannel(m_viTX_IQ_BAND_HIGH, m_sTX_IQ_ARFCN_HIGH);
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, bch_arfcn))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(bch_arfcn)
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_TCHARFCN(m_pRct, m_sTX_IQ_ARFCN_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN_HIGH)
- );
- if (!m_rct_ctrl.RCT_MSTXLevel(m_pRct, m_sTX_IQ_PCL_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL_HIGH)
- );
- if (!m_rct_ctrl.RCT_ConfigTSC(m_pRct, m_cTSC))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TSC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL : " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < TSC = " + IntToStr(m_cTSC)
- );
- if (!m_rct_ctrl.RCT_confIQTuning(m_pRct, m_uiTX_IQ_MEASUREMENT_COUNT))
- {
- CalErrorHandler(WM_MF_AGE8960_CONFIG_IQ_TUNNING_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL : " + m_pRct->as_RCT + " < config IQ tunning fail."
- );
- return false;
- }
- // get OOS
- for (int i=0; i<4; i++)
- {
- if (i <= 2)
- {
- rf_bb_tx_cfg_req.TxTrimI = TrimIQ[i].I;
- rf_bb_tx_cfg_req.TxTrimQ = TrimIQ[i].Q;
- }
- rf_bb_tx_cfg_req.TxOffsetI = OffsetIQ[i].I;
- rf_bb_tx_cfg_req.TxOffsetQ = OffsetIQ[i].Q;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- CHECK_TERMINATE_BY_USER
- MF_rf_tx_level_req->arfcn = m_sTX_IQ_ARFCN_HIGH;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = m_sTX_IQ_PCL_HIGH;
- MF_rf_tx_level_req->frames = -99;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- if( frmFatcory->rbAgilent8960->Checked )
- {
- MF_rf_tx_level_req->burstTypeNB = NB_TX_ALL_ONES_WITHOUT_TSC;
- }
- else
- { MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC;
- }
- if (META_Rf_NB_TX_r(m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- ::ccb_MF_rf_tx_level_TrOff,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(m_sTX_IQ_ARFCN_HIGH) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", power = " + m_sTX_IQ_PCL +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- return false;
- }
- SUSPEND_CAL_THREAD
- Sleep(100);
- // TX IQ gain imbalance
- if (!m_rct_ctrl.RCT_readTxIq(m_pRct, d_SBS[i], d_OOS[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_IQ_TUNNING_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > read TX IQ tunning fail."
- );
- return false;
- }
- if (i<=2)
- {
- if (NAN == d_SBS[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX IQ imbalance fail."
- );
- return false;
- }
- d_PSBS[i] = exp(d_SBS[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " TrimI = " + IntToStr( TrimIQ[i].I ) +
- ", TrimQ = " + IntToStr( TrimIQ[i].Q ) +
- ", SBS = " + Double_To_AnsiString( d_SBS[i] ) +
- ", PSBS = " + Double_To_AnsiString( d_PSBS[i] )
- );
- }
- if (NAN == d_OOS[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX original offset fail."
- );
- return false;
- }
- d_POOS[i] = exp(d_OOS[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " OffsetI = " + IntToStr(OffsetIQ[i].I) +
- ", OffsetQ = " + IntToStr(OffsetIQ[i].Q) +
- ", OOS = " + Double_To_AnsiString(d_OOS[i]) +
- ", POOS = " + Double_To_AnsiString(d_POOS[i])
- );
- Sleep(50);
- STOP_RF
- }
- // TX IQ gain imbalance
- ViReal64 Xt;
- Xt = 14*(d_PSBS[2]-d_PSBS[1]) / (2*(d_PSBS[2]+d_PSBS[1]-2*d_PSBS[0]));
- float fdata = Xt/2.0;
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- trim_IQt_h.I = fdata;
- fdata = -1.0*(Xt - trim_IQt_h.I);
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- trim_IQt_h.Q = fdata;
- if (trim_IQt_h.I > MAX_TRIM_IQ)
- {
- trim_IQt_h.I = MAX_TRIM_IQ;
- }
- else if (trim_IQt_h.I < MIN_TRIM_IQ)
- {
- trim_IQt_h.I = MIN_TRIM_IQ;
- }
- if (trim_IQt_h.Q > MAX_TRIM_IQ)
- {
- trim_IQt_h.Q = MAX_TRIM_IQ;
- }
- else if (trim_IQt_h.Q < MIN_TRIM_IQ)
- {
- trim_IQt_h.Q = MIN_TRIM_IQ;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate Xt = " + Double_To_AnsiString(Xt) + ", TrimI = " + IntToStr(trim_IQt_h.I) +
- ", TrimQ = " + IntToStr(trim_IQt_h.Q)
- );
- // TX DC offset
- fdata = 30*3*(d_POOS[3]-d_POOS[2]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0]));
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt_h.I = fdata;
- fdata= 30*(d_POOS[3]+d_POOS[2]-4*d_POOS[1]+2*d_POOS[0]) / (2*(d_POOS[3]+d_POOS[2]+2*d_POOS[1]-4*d_POOS[0]));
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- offset_IQt_h.Q = fdata;
- if (offset_IQt_h.I > MAX_OFFSET_IQ)
- {
- offset_IQt_h.I = MAX_OFFSET_IQ;
- }
- else if (offset_IQt_h.I < MIN_OFFSET_IQ)
- {
- offset_IQt_h.I = MIN_OFFSET_IQ;
- }
- if (offset_IQt_h.Q > MAX_OFFSET_IQ)
- {
- offset_IQt_h.Q = MAX_OFFSET_IQ;
- }
- else if (offset_IQt_h.Q < MIN_OFFSET_IQ)
- {
- offset_IQt_h.Q = MIN_OFFSET_IQ;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate OffsetI = " + IntToStr(offset_IQt_h.I) +
- ", OffsetQ = " + IntToStr(offset_IQt_h.Q)
- );
- l1cal_txiq.bbtx_trimI_h = trim_IQt_h.I;
- l1cal_txiq.bbtx_trimQ_h = trim_IQt_h.Q;
- l1cal_txiq.bbtx_offsetI_h = offset_IQt_h.I;
- l1cal_txiq.bbtx_offsetQ_h = offset_IQt_h.Q;
- rf_bb_tx_cfg_req.TxTrimI = trim_IQt_h.I;
- rf_bb_tx_cfg_req.TxTrimQ = trim_IQt_h.Q;
- rf_bb_tx_cfg_req.TxOffsetI = offset_IQt_h.I;
- rf_bb_tx_cfg_req.TxOffsetQ = offset_IQt_h.Q;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- #if 0
- // phase calibration
- if (m_pCal->e_bbtxcfg_ver >= BBTXCFG_VER3)
- {
- char TxPhasesel[2] = {0, 3};
- double d_SBS_phase[2];
- double d_PSBS_phase[2];
- char TxPhasesel_min;
- for (int i=0; i<2; i++)
- {
- rf_bb_tx_cfg_req.TxPhasesel = TxPhasesel[i];
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_RF_TX_IQ_FAIL);
- MF_rf_tx_level_req->arfcn = m_sTX_IQ_ARFCN_HIGH;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = m_sTX_IQ_PCL_HIGH;
- MF_rf_tx_level_req->frames = -99;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- if (frmFatcory->rbAgilent8960->Checked)
- {
- MF_rf_tx_level_req->burstTypeNB = NB_TX_ALL_ONES_WITHOUT_TSC;
- }
- else
- {
- MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC;
- }
- if (META_Rf_NB_TX_r(m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- ::ccb_MF_rf_tx_level_TrOff,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(m_sTX_IQ_ARFCN) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", power = " + m_sTX_IQ_PCL +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- return false;
- }
- SUSPEND_CAL_THREAD
- Sleep(100);
- if (!m_rct_ctrl.RCT_readTxIqImbalance(m_pRct, d_SBS_phase[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_IQ_TUNNING_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > read TX IQ tunning fail."
- );
- return false;
- }
- if (NAN == d_SBS_phase[i])
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Get TX IQ imbalance fail."
- );
- return false;
- }
- d_PSBS_phase[i] = exp(d_SBS_phase[i]/10.0*logl(10.0));
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " TxPhasesel = " + IntToStr(TxPhasesel[i]) +
- ", SBS = " + Double_To_AnsiString(d_SBS_phase[i]) +
- ", PSBS = " + Double_To_AnsiString(d_PSBS_phase[i])
- );
- Sleep(50);
- RestartTimerCal(WM_MF_RF_TX_IQ_FAIL);
- STOP_RF
- }
- fdata = (TxPhasesel[1]*TxPhasesel[1] + 4*d_PSBS_phase[0] - 4*d_PSBS_phase[1])/(2*TxPhasesel[1]);
- fdata += (fdata>=0) ? 0.5 : -0.5 ;
- TxPhasesel_min = (char) fdata;
- if (TxPhasesel_min > MAX_PHASESEL)
- {
- TxPhasesel_min = MAX_PHASESEL;
- }
- else if (TxPhasesel_min < MIN_PHASESEL)
- {
- TxPhasesel_min = MIN_PHASESEL;
- }
- l1cal_txiq.bbtx_phsel_h = (unsigned char) TxPhasesel_min;
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate TxPhasesel = " + IntToStr(TxPhasesel_min)
- );
- }
- #endif
- } // MT6140
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================== TX IQ calibration end ================== "
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== TX IQ check begin =================== "
- );
- m_viTX_IQ_BAND = Get_AgeBand(m_asTX_IQ_BAND);
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, m_viTX_IQ_BAND))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(m_viTX_IQ_BAND)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(m_viTX_IQ_BAND)
- );
- if (age1960_PCS1900_BAND == m_viTX_IQ_BAND)
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_AFC_SELECT_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 1"
- );
- return false;
- }
- }
- else
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_AFC_SELECT_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 0"
- );
- return false;
- }
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- bch_arfcn = ::Get_SeperateChannel(m_viTX_IQ_BAND, m_sTX_IQ_ARFCN);
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, bch_arfcn))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_TCHARFCN(m_pRct, m_sTX_IQ_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN)
- );
- if (!m_rct_ctrl.RCT_MSTXLevel(m_pRct, m_sTX_IQ_PCL))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL)
- );
- // set BBTxCfg
- rf_bb_tx_cfg_req.TxTrimI = trim_IQt.I;
- rf_bb_tx_cfg_req.TxTrimQ = trim_IQt.Q;
- rf_bb_tx_cfg_req.TxOffsetI = offset_IQt.I;
- rf_bb_tx_cfg_req.TxOffsetQ = offset_IQt.Q;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- STOP_RF
- MF_rf_tx_level_req->arfcn = m_sTX_IQ_ARFCN;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = m_sTX_IQ_PCL;
- MF_rf_tx_level_req->frames = -99;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- if( frmFatcory->rbAgilent8960->Checked )
- {
- MF_rf_tx_level_req->burstTypeNB = NB_TX_ALL_ONES_WITHOUT_TSC;
- }
- else
- { MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC;
- }
- if (META_Rf_NB_TX_r(m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- ::ccb_MF_rf_tx_level_TrOff,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS
- )
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(m_sTX_IQ_ARFCN) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", power = " + IntToStr(m_sTX_IQ_PCL) +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- return false;
- }
- SUSPEND_CAL_THREAD
- // TX IQ gain imbalance check
- double d_SBS_Check;
- double d_OOS_Check;
- Sleep(100);
- if (!m_rct_ctrl.RCT_readTxIq(m_pRct, d_SBS_Check, d_OOS_Check))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_IQ_TUNNING_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " > read TX IQ tunning fail."
- );
- return false;
- }
- if (d_OOS_Check > m_dTX_IQ_DC_OFFSET_MAX ||
- d_SBS_Check > m_dTX_IQ_GAIN_IMBALANCE_MAX
- )
- {
- l1cal_txiq.bbtx_isCalibrated = 0;
- }
- else
- {
- l1cal_txiq.bbtx_isCalibrated = BBTX_CALIBRATED_SCALE;
- }
- if ((RF_ID_A60111A == m_pCal->ui_rf_id) ||
- (RF_ID_AERO2E == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140A == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140B == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140C == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140D == m_pCal->ui_rf_id)
- )
- {
- m_viTX_IQ_BAND_HIGH = Get_AgeBand(m_asTX_IQ_BAND_HIGH);
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, m_viTX_IQ_BAND_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(m_viTX_IQ_BAND_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < Band = "+
- ViBand_To_Str(m_viTX_IQ_BAND_HIGH)
- );
- if (age1960_PCS1900_BAND == m_viTX_IQ_BAND_HIGH)
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_AFC_SELECT_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 1"
- );
- return false;
- }
- }
- else
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_AFC_SELECT_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 0"
- );
- return false;
- }
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- short bch_arfcn = ::Get_SeperateChannel(m_viTX_IQ_BAND_HIGH, m_sTX_IQ_ARFCN_HIGH);
- if (!m_rct_ctrl.RCT_BCHARFCN( m_pRct, bch_arfcn) )
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(bch_arfcn)
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_TCHARFCN(m_pRct, m_sTX_IQ_ARFCN_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_sTX_IQ_ARFCN_HIGH)
- );
- if (!m_rct_ctrl.RCT_MSTXLevel(m_pRct, m_sTX_IQ_PCL_HIGH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL_HIGH)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr(m_sTX_IQ_PCL_HIGH)
- );
- // set BBTxCfg
- rf_bb_tx_cfg_req.TxTrimI = trim_IQt_h.I;
- rf_bb_tx_cfg_req.TxTrimQ = trim_IQt_h.Q;
- rf_bb_tx_cfg_req.TxOffsetI = offset_IQt_h.I;
- rf_bb_tx_cfg_req.TxOffsetQ = offset_IQt_h.Q;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_MF;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pCal->e_bbtxcfg_ver, rf_bb_tx_cfg_req);
- RestartTimerCal(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- SUSPEND_CAL_THREAD
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_SET_BB_TX_CFG_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < RF set BB TX CFG fail."
- );
- return false;
- }
- STOP_RF
- MF_rf_tx_level_req->arfcn = m_sTX_IQ_ARFCN_HIGH;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = m_sTX_IQ_PCL_HIGH;
- MF_rf_tx_level_req->frames = -99;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- if (frmFatcory->rbAgilent8960->Checked)
- {
- MF_rf_tx_level_req->burstTypeNB = NB_TX_ALL_ONES_WITHOUT_TSC;
- }
- else
- { MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC;
- }
- if (META_Rf_NB_TX_r(m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- ::ccb_MF_rf_tx_level_TrOff,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS
- )
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(m_sTX_IQ_ARFCN_HIGH) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", power = " + IntToStr(m_sTX_IQ_PCL_HIGH) +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- return false;
- }
- SUSPEND_CAL_THREAD
- Sleep(100);
- // TX IQ gain imbalance & OOS check
- if (!m_rct_ctrl.RCT_readTxIq(m_pRct, d_SBS_Check_h, d_OOS_Check_h))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_IQ_TUNNING_FAIL);
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960 > read TX IQ tunning fail."
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : CMU 200 > read TX IQ tunning fail."
- );
- }
- return false;
- }
- if( d_OOS_Check > m_dTX_IQ_DC_OFFSET_MAX ||
- d_SBS_Check > m_dTX_IQ_GAIN_IMBALANCE_MAX ||
- d_OOS_Check_h > m_dTX_IQ_DC_OFFSET_MAX ||
- d_SBS_Check_h > m_dTX_IQ_GAIN_IMBALANCE_MAX
- )
- {
- l1cal_txiq.bbtx_isCalibrated = 0;
- }
- else
- {
- l1cal_txiq.bbtx_isCalibrated = BBTX_CALIBRATED_SCALE;
- }
- }
- S_BBTXPARA_CHANGE_FLAG_T flag;
- flag.b_bbtx_common_mode_voltage = true;
- flag.b_bbtx_gain = true;
- flag.b_bbtx_calrcsel = true;
- flag.b_bbtx_trimI = true;
- flag.b_bbtx_trimQ = true;
- flag.b_bbtx_offsetI = true;
- flag.b_bbtx_offsetQ = true;
- flag.b_bbtx_isCalibrated = true;
- flag.b_apc_bat_low_voltage = true;
- flag.b_apc_bat_high_voltage = true;
- flag.b_apc_bat_low_temperature = true;
- flag.b_apc_bat_high_temperature = true;
- flag.b_bbtx_common_mode_voltage_h = true;
- flag.b_bbtx_gain_h = true;
- flag.b_bbtx_calrcsel_h = true;
- flag.b_bbtx_trimI_h = true;
- flag.b_bbtx_trimQ_h = true;
- flag.b_bbtx_offsetI_h = true;
- flag.b_bbtx_offsetQ_h = true;
- flag.b_bbtx_phsel = true;
- flag.b_bbtx_phsel_h = true;
- MF_rf_txiq_ptr->Set_BBTXChangeFlag(flag);
- MF_rf_txiq_ptr->Set_BBTXParameters(l1cal_txiq);
- WriteTxDcOffsetCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath );
- MF_rf_txiq_ptr->ConfirmCallback = ::ccb_write_txiq_to_nvram;
- MF_rf_txiq_ptr->REQ_Write_To_NVRAM_Start(m_pCal->ui_rf_id, m_pCal->e_bbtxcfg_ver);
- RestartTimerCal (WM_MF_NVRAM_TXIQ_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_txiq_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_TXIQ_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_TXIQ_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_TXIQ_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< Write txiq value to NVRAM fail "
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< Write TXIQ value to NVRAM"
- );
- if (d_OOS_Check > m_dTX_IQ_DC_OFFSET_MAX)
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX IQ calibration." +
- " , Check TX DC offset = " + Double_To_AnsiString(d_OOS_Check) +
- ", Max TX DC offset = " + Double_To_AnsiString(m_dTX_IQ_DC_OFFSET_MAX)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: TX IQ calibration." +
- " , Check TX DC offset = " + Double_To_AnsiString(d_OOS_Check) +
- ", Max TX DC offset = " + Double_To_AnsiString(m_dTX_IQ_DC_OFFSET_MAX)
- );
- // TX IQ gain imbalnce check
- if (d_SBS_Check > m_dTX_IQ_GAIN_IMBALANCE_MAX)
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX IQ calibration." +
- " , Check TX IQ gain imbalance = " + Double_To_AnsiString(d_SBS_Check) +
- ", Max TX IQ gain imbalance = " + Double_To_AnsiString(m_dTX_IQ_GAIN_IMBALANCE_MAX)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: TX IQ calibration." +
- " , Check TX IQ gain imbalance = " + Double_To_AnsiString(d_SBS_Check) +
- ", Max TX IQ gain imbalance = " + Double_To_AnsiString(m_dTX_IQ_GAIN_IMBALANCE_MAX)
- );
- if ((RF_ID_A60111A == m_pCal->ui_rf_id) ||
- (RF_ID_AERO2E == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140A == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140B == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140C == m_pCal->ui_rf_id) ||
- (RF_ID_MT6140D == m_pCal->ui_rf_id)
- )
- {
- if (d_OOS_Check_h > m_dTX_IQ_DC_OFFSET_MAX_HIGH)
- {
- CalErrorHandler(WM_MF_RF_TX_IQ_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX IQ calibration." +
- " , Check high band TX DC offset = " + Double_To_AnsiString(d_OOS_Check_h) +
- ", Max TX DC offset = " + Double_To_AnsiString( m_dTX_IQ_DC_OFFSET_MAX_HIGH )
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: TX IQ calibration." +
- " , Check high band TX DC offset = " + Double_To_AnsiString(d_OOS_Check_h) +
- ", Max TX DC offset = " + Double_To_AnsiString(m_dTX_IQ_DC_OFFSET_MAX_HIGH )
- );
- // TX IQ gain imbalnce check
- if( d_SBS_Check_h > m_dTX_IQ_GAIN_IMBALANCE_MAX )
- {
- CalErrorHandler( WM_MF_RF_TX_IQ_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX IQ calibration." +
- " , Check high band TX IQ gain imbalance = " + Double_To_AnsiString(d_SBS_Check_h) +
- ", Max TX IQ gain imbalance = " + Double_To_AnsiString(m_dTX_IQ_GAIN_IMBALANCE_MAX_HIGH)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " PASS: TX IQ calibration." +
- " , Check high band TX IQ gain imbalance = " + Double_To_AnsiString(d_SBS_Check_h) +
- ", Max TX IQ gain imbalance = " + Double_To_AnsiString(m_dTX_IQ_GAIN_IMBALANCE_MAX_HIGH)
- );
- }
- frmFatcory->DisableAllCalTimer();
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_IQ_CALIBRATION_DONE,
- 0,
- 0
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== TX IQ check end ===================== "
- );
- return true;
- }
- //------------------------------------------------------------------------------
- ViReal64 __fastcall T_META_factory_calibration::get_TX_Original_Offset(ViReal64 *p_IQTFreqs, ViReal64 *p_IQTResults, ViInt32 IQTTuningCount)
- {
- for(int i=0; i<IQTTuningCount; i++)
- {
- if( *(p_IQTFreqs+i) == IQT_ORIGINAL_OFFSET_FREQ )
- {
- return *(p_IQTResults+i);
- }
- }
- return NAN;
- }