Tool/software:
I want to dynamically configure the parameters of the AFE using the CAFE library. To achieve this, I followed the document "Implementing the CAFE Library in Vitis."
I copied the CAFE library's header files into the include
folder of my project, and the source files into the Src
folder. I then updated the read, write, log, and delay functions accordingly.
Next, I used the AFE.saveCAfeParamsFile()
function in the AFE79xx software to save the afe79xxParameters
, and replaced the contents of the init_tiAfe79DeviceInfo_t
structure with the newly generated file, as shown below:
void init_tiAfe79DeviceInfo_t() { afe79SystemParamsStruct systemParams = { 121,//chipId 19,//chipVersion 245760,//X 491520,//FRef 2949120,//FadcRx 2949120,//FadcFb 11796480,//Fdac {1, 1, 1, 1},//rxEnable {1, 1},//fbEnable {0, 0, 0, 0},//txEnable 0,//RRFMode {0, 1, 2},//adcSelect0 {0, 1, 2},//adcSelect1 2,//modeTdd 0,//externalClockRx 0,//externalClockTx 0,//useSpiSysref 1,//continuousSysref 0,//sysrefTermination 1,//spiMode 0,//ncoFreqMode {0, 0},//halfRateModeRx {0, 0},//halfRateModeFb {0, 0},//halfRateModeTx {0, 0},//enableAdcAveragingMode {0, 0},//combineDucMode {0, 0},//enableTxFbLoopbackLowLatencyMode {12, 12, 12, 12},//ddcFactorRx {{{9000000, 9000000}, {9000000, 9000000}, {9000000, 9000000}, {9000000, 9000000}}, {{9010000, 9010000}, {9010000, 9010000}, {9010000, 9010000}, {9010000, 9010000}}},//rxNco {0, 0, 0, 0},//numBandsRx {2, 2, 2, 2},//numRxNCOB0 {1, 1, 1, 1},//numRxNCOB1 {0, 0},//ncoRxMode 0,//broadcastRxNcoSel {12, 12},//ddcFactorFb {{2600000, 1800000, 1800000, 1800000}, {2600000, 1900000, 1900000, 1900000}},//fbNco {1, 1},//numFbNCO 0,//ncoFbMode {48, 48, 48, 48},//ducFactorTx {{{9000000, 9000000}, {9000000, 9000000}, {9000000, 9000000}, {9000000, 9000000}}, {{1800000, 2600000}, {1800000, 2600000}, {1800000, 2600000}, {1800000, 2600000}}},//txNco {0, 0, 0, 0},//numBandsTx {1, 1, 1, 1},//numTxNCOB0 {1, 1, 1, 1},//numTxNCOB1 {0, 0},//ncoTxMode 0,//broadcastTxNcoSel 0,//enableDacInterleavedMode 0,//jesdLoopbackEn 1,//syncLoopBack 0,//jesdABLvdsSync 0,//jesdCDLvdsSync 0,//executeLinkUpSequenceSeparately {1, 1, 1, 1},//LMFSHdRx_L {2, 2, 2, 2},//LMFSHdRx_M {4, 4, 4, 4},//LMFSHdRx_F {1, 1, 1, 1},//LMFSHdRx_S {0, 0, 0, 0},//LMFSHdRx_Hd {0, 0, 0, 0},//LMFSHdRx_Misc {2, 2},//LMFSHdFb_L {2, 2},//LMFSHdFb_M {2, 2},//LMFSHdFb_F {1, 1},//LMFSHdFb_S {0, 0},//LMFSHdFb_Hd {0, 0},//LMFSHdFb_Misc {0, 0},//jesdSystemMode {0, 0},//jesdTxProtocol {0, 0, 0, 0},//rxJesdTxScr {0, 0},//fbJesdTxScr {32, 32, 32, 32},//rxJesdTxK {32, 32},//fbJesdTxK {0, 0, 0, 0},//rxJesdTxSyncMux {0, 0},//fbJesdTxSyncMux 1,//setIlaParams {8, 8, 2, 8, 8, 2},//jesdTxIlaM {4, 4, 2, 4, 4, 2},//jesdTxIlaL {0, 1, 2, 3, 4, 5, 6, 7},//jesdTxIlaLid {0, 0, 0, 0, 0, 0, 0, 0},//serdesTxLanePolarity {0, 1, 2, 3, 4, 5, 6, 7},//jesdTxLaneMux 1,//adcDataMuxEn {0, 1, 2, 3, 4, 5, 6, 7},//rxDataMux {0, 1},//fbDataMux 0,//jesdSendZeroesInTddOff {0, 0, 0, 0, 0, 0, 0, 0},//serdesTxPreCursor {0, 0, 0, 0, 0, 0, 0, 0},//serdesTxPostCursor {3, 0, 0, 0, 0, 0, 0, 3},//serdesTxMainCursor {1, 1, 1, 1},//LMFSHdTx_L {2, 2, 2, 2},//LMFSHdTx_M {4, 4, 4, 4},//LMFSHdTx_F {1, 1, 1, 1},//LMFSHdTx_S {0, 0, 0, 0},//LMFSHdTx_Hd {0, 0, 0, 0},//LMFSHdTx_Misc {0, 0, 0, 0},//jesdRxSyncMux {0, 0},//jesdRxProtocol {0, 0, 0, 0, 0, 0, 0, 0},//serdesRxLanePolarity {0, 1, 2, 3, 4, 5, 6, 7},//jesdRxLaneMux {4, 4, 4, 4},//jesdRxRbd {0, 0, 0, 0},//jesdRxScr {32, 32, 32, 32},//jesdRxK {0, 0, 0, 0},//jesdRxInitLmfcCounter 1,//dacDataMuxEn {0, 1, 2, 3, 4, 5, 6, 7},//txDataMux 0,//serdesManualCTLEEn {6, 6, 6, 6, 6, 6, 6, 6},//serdesManualCTLE {0, 0, 0, 0},//defaultRxDsa {0, 0},//defaultFbDsa {0, 0, 0, 0},//defaultTxDsa 0,//enableRxDsaCalibration {0, 25},//rxDsaGainRange 0,//enableTxDsaCalibration {0, 29},//txDsaGainRange 2,//reliabilityDetectorDecayMode 0,//fbDsaPerTxEn {0, 0, 0, 0},//fbDsaPerTx 0,//txToFbMode 1,//spiInUseForPllAccess {// agcParams {// agcParams 0 1,//chainen 0,//agcMode 1,//tdd_freeze_agc 600,//blank_time_extcomp 0,//en_agcfreeze_pin 0,//minDsaAttn 50,//maxDsaAttn {0, 1, 0},//atken {6, 2},//atksize {17, 17},//atkwinlength {4, 8, 56},//atkthreshold {25, 75},//atkNumHitsRel {8, 8},//atkNumHitsAbs {0, 1, 0},//decayen {6, 2},//decaysize 8738,//decaywinlength {56, 32, 80},//decaythreshold {75, 25},//decayNumHitsRel {8, 8},//decayNumHitsAbs 0,//rfdeten 1,//custRfMode 8,//rfdetstepsize 3,//rfdetThreshold 0,//rfdetNumhitsmode 8,//rfdetnumhits 0,//lnaEn 0,//extLnaTempModel 0,//singleDualBandMode 0,//enBandDet 0,//tapOffPoint 12,//lnagain0 0,//lnaphase0 12,//lnagain1 0,//lnaphase1 6,//lnaGainMargin 0,//startTemp 1,//stepTemp 5,//NumStep 0,//temp_idxB0 0,//temp_idxB1 16448,//pin0sel 16432,//pin1sel 16416,//pin2sel 16400,//pin3sel 0,//pkDetPinLsbSel 50,//pulseExpansionCount 0,//pkDetOnPenultimateLsb 0,//gpioRstEnable 0,//dsaInit 1,//dsaStep 0,//maxInpPinDelay 0,//alcEn 0,//alcMode 32,//totalGainRange 0,//minAttnAlc 1,//useMinAttnAgc 0,//fltPtMode 1,//fltPtFmt 6,//stepSize 3,//nBitIndex 0,//indexInvert 0,//indexSwapIQ 0,//sigBackOff 1,//gainChangeIndEn 306,//outputDgcPinDelay }, {// agcParams 1 2,//chainen 0,//agcMode 1,//tdd_freeze_agc 600,//blank_time_extcomp 0,//en_agcfreeze_pin 0,//minDsaAttn 50,//maxDsaAttn {0, 1, 0},//atken {6, 2},//atksize {17, 17},//atkwinlength {4, 8, 56},//atkthreshold {25, 75},//atkNumHitsRel {8, 8},//atkNumHitsAbs {0, 1, 0},//decayen {6, 2},//decaysize 8738,//decaywinlength {56, 32, 80},//decaythreshold {75, 25},//decayNumHitsRel {8, 8},//decayNumHitsAbs 0,//rfdeten 1,//custRfMode 8,//rfdetstepsize 3,//rfdetThreshold 0,//rfdetNumhitsmode 8,//rfdetnumhits 0,//lnaEn 0,//extLnaTempModel 0,//singleDualBandMode 0,//enBandDet 0,//tapOffPoint 12,//lnagain0 0,//lnaphase0 12,//lnagain1 0,//lnaphase1 6,//lnaGainMargin 0,//startTemp 1,//stepTemp 5,//NumStep 0,//temp_idxB0 0,//temp_idxB1 16448,//pin0sel 16432,//pin1sel 16416,//pin2sel 16400,//pin3sel 0,//pkDetPinLsbSel 50,//pulseExpansionCount 0,//pkDetOnPenultimateLsb 0,//gpioRstEnable 0,//dsaInit 1,//dsaStep 0,//maxInpPinDelay 0,//alcEn 0,//alcMode 32,//totalGainRange 0,//minAttnAlc 1,//useMinAttnAgc 0,//fltPtMode 1,//fltPtFmt 6,//stepSize 3,//nBitIndex 0,//indexInvert 0,//indexSwapIQ 0,//sigBackOff 1,//gainChangeIndEn 306,//outputDgcPinDelay }, {// agcParams 2 4,//chainen 0,//agcMode 1,//tdd_freeze_agc 600,//blank_time_extcomp 0,//en_agcfreeze_pin 0,//minDsaAttn 50,//maxDsaAttn {0, 1, 0},//atken {6, 2},//atksize {17, 17},//atkwinlength {4, 8, 56},//atkthreshold {25, 75},//atkNumHitsRel {8, 8},//atkNumHitsAbs {0, 1, 0},//decayen {6, 2},//decaysize 8738,//decaywinlength {56, 32, 80},//decaythreshold {75, 25},//decayNumHitsRel {8, 8},//decayNumHitsAbs 0,//rfdeten 1,//custRfMode 8,//rfdetstepsize 3,//rfdetThreshold 0,//rfdetNumhitsmode 8,//rfdetnumhits 0,//lnaEn 0,//extLnaTempModel 0,//singleDualBandMode 0,//enBandDet 0,//tapOffPoint 12,//lnagain0 0,//lnaphase0 12,//lnagain1 0,//lnaphase1 6,//lnaGainMargin 0,//startTemp 1,//stepTemp 5,//NumStep 0,//temp_idxB0 0,//temp_idxB1 16448,//pin0sel 16432,//pin1sel 16416,//pin2sel 16400,//pin3sel 0,//pkDetPinLsbSel 50,//pulseExpansionCount 0,//pkDetOnPenultimateLsb 0,//gpioRstEnable 0,//dsaInit 1,//dsaStep 0,//maxInpPinDelay 0,//alcEn 0,//alcMode 32,//totalGainRange 0,//minAttnAlc 1,//useMinAttnAgc 0,//fltPtMode 1,//fltPtFmt 6,//stepSize 3,//nBitIndex 0,//indexInvert 0,//indexSwapIQ 0,//sigBackOff 1,//gainChangeIndEn 306,//outputDgcPinDelay }, {// agcParams 3 8,//chainen 0,//agcMode 1,//tdd_freeze_agc 600,//blank_time_extcomp 0,//en_agcfreeze_pin 0,//minDsaAttn 50,//maxDsaAttn {0, 1, 0},//atken {6, 2},//atksize {17, 17},//atkwinlength {4, 8, 56},//atkthreshold {25, 75},//atkNumHitsRel {8, 8},//atkNumHitsAbs {0, 1, 0},//decayen {6, 2},//decaysize 8738,//decaywinlength {56, 32, 80},//decaythreshold {75, 25},//decayNumHitsRel {8, 8},//decayNumHitsAbs 0,//rfdeten 1,//custRfMode 8,//rfdetstepsize 3,//rfdetThreshold 0,//rfdetNumhitsmode 8,//rfdetnumhits 0,//lnaEn 0,//extLnaTempModel 0,//singleDualBandMode 0,//enBandDet 0,//tapOffPoint 12,//lnagain0 0,//lnaphase0 12,//lnagain1 0,//lnaphase1 6,//lnaGainMargin 0,//startTemp 1,//stepTemp 5,//NumStep 0,//temp_idxB0 0,//temp_idxB1 16448,//pin0sel 16432,//pin1sel 16416,//pin2sel 16400,//pin3sel 0,//pkDetPinLsbSel 50,//pulseExpansionCount 0,//pkDetOnPenultimateLsb 0,//gpioRstEnable 0,//dsaInit 1,//dsaStep 0,//maxInpPinDelay 0,//alcEn 0,//alcMode 32,//totalGainRange 0,//minAttnAlc 1,//useMinAttnAgc 0,//fltPtMode 1,//fltPtFmt 6,//stepSize 3,//nBitIndex 0,//indexInvert 0,//indexSwapIQ 0,//sigBackOff 1,//gainChangeIndEn 306,//outputDgcPinDelay }, }, { {// papParams 0 0,//enable 1,//maEnable 4,//maNumSample 1,//maWindowCntr 1,//maWindowCntrTh -1440,//maThreshB0 -1440,//maThreshB1 -1440,//maThreshComb 1,//hpfEnable 1,//hpfNumSample 0,//hpfWindowCntr 0,//hpfWindowCntrTh -480,//hpfThreshB0 -480,//hpfThreshB1 -480,//hpfThreshComb 0,//multMode 128,//rampDownStartVal 200,//waitCounter 5,//gainStepSize 5,//attnStepSize 2,//amplUpdateCycles 50,//triggerClearToRampUp 50,//triggerToRampDown 0,//detectInWaitState 0,//rampStickyMode 14,//alarmChannelMask 64,//alarmMask 1,//alarmPinDynamicMode 1000,//alarmPulseGPIO }, {// papParams 1 0,//enable 1,//maEnable 4,//maNumSample 1,//maWindowCntr 1,//maWindowCntrTh -1440,//maThreshB0 -1440,//maThreshB1 -1440,//maThreshComb 1,//hpfEnable 1,//hpfNumSample 0,//hpfWindowCntr 0,//hpfWindowCntrTh -480,//hpfThreshB0 -480,//hpfThreshB1 -480,//hpfThreshComb 0,//multMode 128,//rampDownStartVal 200,//waitCounter 5,//gainStepSize 5,//attnStepSize 2,//amplUpdateCycles 50,//triggerClearToRampUp 50,//triggerToRampDown 0,//detectInWaitState 0,//rampStickyMode 14,//alarmChannelMask 64,//alarmMask 1,//alarmPinDynamicMode 1000,//alarmPulseGPIO }, {// papParams 2 0,//enable 1,//maEnable 4,//maNumSample 1,//maWindowCntr 1,//maWindowCntrTh -1440,//maThreshB0 -1440,//maThreshB1 -1440,//maThreshComb 1,//hpfEnable 1,//hpfNumSample 0,//hpfWindowCntr 0,//hpfWindowCntrTh -480,//hpfThreshB0 -480,//hpfThreshB1 -480,//hpfThreshComb 0,//multMode 128,//rampDownStartVal 200,//waitCounter 5,//gainStepSize 5,//attnStepSize 2,//amplUpdateCycles 50,//triggerClearToRampUp 50,//triggerToRampDown 0,//detectInWaitState 0,//rampStickyMode 14,//alarmChannelMask 64,//alarmMask 1,//alarmPinDynamicMode 1000,//alarmPulseGPIO }, {// papParams 3 0,//enable 1,//maEnable 4,//maNumSample 1,//maWindowCntr 1,//maWindowCntrTh -1440,//maThreshB0 -1440,//maThreshB1 -1440,//maThreshComb 1,//hpfEnable 1,//hpfNumSample 0,//hpfWindowCntr 0,//hpfWindowCntrTh -480,//hpfThreshB0 -480,//hpfThreshB1 -480,//hpfThreshComb 0,//multMode 128,//rampDownStartVal 200,//waitCounter 5,//gainStepSize 5,//attnStepSize 2,//amplUpdateCycles 50,//triggerClearToRampUp 50,//triggerToRampDown 0,//detectInWaitState 0,//rampStickyMode 14,//alarmChannelMask 64,//alarmMask 1,//alarmPinDynamicMode 1000,//alarmPulseGPIO }, }, };
Then in main, included the header files and instantiated the AFE structure like this
afe79InstDeviceInfo tiAfe79DeviceInfo_t= {0}; //Instantiating the AFE Structure init_tiAfe79DeviceInfo_t (&tiAfe79DeviceInfo_t); //Loading the parameters into the AFE Sysparams Structure AFE79FNP (setAfeLogLvl) (&tiAfe79DeviceInfo_t, 2); //Setting log level
Then called the checkdevicehealth() function like this,
uint16_t allOk = 0; AFE79FNP (checkDeviceHealth) (&tiAfe79DeviceInfo_t, &allOk); //This function Reads the complete device health and returns it as a pointer. xil_printf("allOk: %d\r\n", allOk);
Its output is;
Then called readRxNco() function like this:
uint8_t ch_no = 1; uint8_t band = 1; uint8_t nco = 0; uint32_t read_nco_freq = 0; AFE79FNP (readRxNco ) (&tiAfe79DeviceInfo_t, ch_no, band, nco, &read_nco_freq);
Its output is;
I have configured NCO frequency of this channel as 9Ghz but it read as 82Khz. Can you please guide me what's the issue.
Similarly when I update the NCO using following code;
uint8_t ch_no = 1; uint8_t band = 1; uint8_t nco = 0; uint32_t nco_freq = 9200000; uint32_t read_nco_freq = 0; AFE79FNP (updateRxNco ) (&tiAfe79DeviceInfo_t, ch_no, nco_freq, band, nco);
Its result is as follows;
Could you please guide me on where I might be wrong?