Part Number:AWR1642BOOST
您好,我使用的是:D:\zj\AutomotiveToolbox\AutomotiveToolbox4.11\new\mmwave_industrial_toolbox_4_11_0\labs\Level_Sensing\src\16xx
我在其下属high_accuracy_16xx_dss/RADARDEMO_highAccuRangeProc_priv.c这个文件中,为了实现补0提高测距精度,我在其开头定义了两个数组,如下图
并在后续对其进行了初始化,将ADC的512个点赋予第一个数组addzeros111,然后将后续的初始化为0。然后调用dft函数对其进行运算。奇怪的是,只有这个数组大小为2*512,也就是和DEMO原来数组大小一样的时候才能正常运行,一旦超出这个大小,都会出现以下错误
我不能理解是为什么,我已经查看过DFT函数,其是根据输入的数组大小自适应调整其内部函数变量的,不存在锁定某一个值的情况,困扰了我很久了,希望有专家可以跟进一下,我将我的代码附在下面以供调用,我只修改了这一个文件,因此您可以在您的Automotive工具箱中替换它以分析。希望有人可以给出我一个可以运行的补0fft的数组代码,我的需求是将其补到4500个点左右,如果是复数采样则需要2*4500=9000个float数组。需要两个这样的数组,一个用来放原始数据,一个用来放dft之后的数据。
/*!* \fileRADARDEMO_highAccuRangeProc_priv.c * * \briefWindowing functions for range processing. * * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/*** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met: * *Redistributions of source code must retain the above copyright*notice, this list of conditions and the following disclaimer. * *Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the*documentation and/or other materials provided with the*distribution. * *Neither the name of Texas Instruments Incorporated nor the names of *its contributors may be used to endorse or promote products derived *from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include "RADARDEMO_highAccuRangeProc_priv.h" #ifdef _TMS320C6X #include "c6x.h" #endif #ifdef ARMVERSION extern void dft(int size, float * input, float * output); #endif #ifndef ARMVERSION #pragma DATA_SECTION(addzeros111,".l3data"); float addzeros111[4*512]; #pragma DATA_SECTION(addzerosoutput122,".l3data"); float addzerosoutput122[4*512]; /*!\fnRADARDEMO_highAccuRangeProc_accumulateInput\briefAccumulate signals from all chirps and convert to floating-point format with 1D windowing.\param[in]nSamplesPerChirpNumber of samples per chirp.\param[in]fftSize1D1D FFT size.\param[in]nChirpPerFrameNumber of chirps per frame.\param[in]fftWin1DInput pointer to 1D window function.\param[in]fftWin1DSizeNumber of ADC bits.\param[in]inputPtrPointer to input signal.\param[in]chirpIndFlag to enable DC adjustment for ADC samples when set to 1. Otherwise, no preprocessing for ADC samples.\param[out]outputPtrPointer to the output signal.\prenone\postnone*/ void RADARDEMO_highAccuRangeProc_accumulateInput(IN uint32_t nSamplesPerChirp,IN uint32_t fftSize1D,IN uint32_t nChirpPerFrame,IN float* RESTRICT fftWin1D, IN int16_t fftWin1DSize, IN cplx16_t * RESTRICT inputPtr, IN int32_t chirpInd, OUT float * outputPtr) {int32_t i;float * tempOutputPtr;if (chirpInd == 0){for( i = (int32_t)nSamplesPerChirp - 1; i >= 0; i--){*outputPtr++=(float)inputPtr->real;*outputPtr++=(float)inputPtr->imag;inputPtr++;}}else{tempOutputPtr=outputPtr;for( i = (int32_t)nSamplesPerChirp - 1; i >= 0; i--){*tempOutputPtr+++= (float)inputPtr->real;*tempOutputPtr+++= (float)inputPtr->imag;inputPtr++;}if (chirpInd == ((int32_t)nChirpPerFrame - 1)){float fwin1D;float *tempOutputPtr;tempOutputPtr=&outputPtr[2*nSamplesPerChirp - 1];for( i = fftWin1DSize - 1; i >= 0; i--){fwin1D=*fftWin1D++;*outputPtr=*outputPtr * fwin1D;outputPtr++;*outputPtr=*outputPtr * fwin1D;outputPtr++;*tempOutputPtr=*tempOutputPtr * fwin1D;tempOutputPtr--;*tempOutputPtr=*tempOutputPtr * fwin1D;tempOutputPtr--;}if (((int32_t)fftSize1D - (int32_t)nSamplesPerChirp) > 0){tempOutputPtr=&outputPtr[2*nSamplesPerChirp];for( i = 0; i < ((int32_t)fftSize1D - (int32_t)nSamplesPerChirp); i++);{*tempOutputPtr++=0.f;*tempOutputPtr++=0.f;}}}} } /*!\fnRADARDEMO_highAccuRangeProc_rangeEst\briefWindowing function for 2D FFT and prepare for the input.\param[in]highAccuRangeHandleHandle to the module.\param[out]estRangeEstimated range.\param[out]deltaPhaseEstEstimated delta phase.\param[out]estLinearSNREstimated SNR.\prenone\postnone*/ void RADARDEMO_highAccuRangeProc_rangeEst(IN RADARDEMO_highAccuRangeProc_handle *highAccuRangeHandle, OUT float * estRange, OUT float * deltaPhaseEst, OUT float * estLinearSNR) {int32_ti, j, rad1D, coarseRangeInd;unsigned char* brev = NULL;floattotalPower, max, ftemp, sigPower, * RESTRICT powerPtr;floatfinput, * RESTRICT inputPtr, * RESTRICT inputPtr1,* RESTRICT inputPtr3,* RESTRICT inputPtr4;int32_ti1, j1, k1, coarseRangeInd1 = highAccuRangeHandle->coarseRangeInd;floatmax1, ftemp1;int32_tzoomStartInd2, zoomEndInd2, itemp2, tempIndFine1, tempIndFine2, tempIndCoarse, indMask, shift;int32_tfineRangeInd, tempFineSearchIdx, tempCoarseSearchIdx;float*RESTRICT inputPtr2, *RESTRICT wncPtr, *RESTRICT wnfPtr, sigAccReal, sigAccImag;floatfreqFineEst, fdelta, finputReal, finputImag, tempReal, tempImag;j = highAccuRangeHandle->log2fft1DSize;if ((j & 1) == 0)rad1D = 4;elserad1D = 2; #if(1)/* copy to scratch is needed because FFT function will corrupt the input. We need to preserve if for zoom-in FFT */inputPtr=(float *) highAccuRangeHandle->inputSig;inputPtr1=(float *) &addzeros111[0];inputPtr4=(float *) &addzerosoutput122[0];for (i = 0; i <((int32_t)highAccuRangeHandle->fft1DSize)*2; i++ ){if(i<(int32_t)highAccuRangeHandle->fft1DSize){*inputPtr1++=*inputPtr++;*inputPtr1++=*inputPtr++;*inputPtr4++=0;*inputPtr4++=0;}else{*inputPtr1++= 0 ;*inputPtr1++= 0 ;*inputPtr4++= 0 ;*inputPtr4++= 0;}}inputPtr1=(float *) &addzeros111[0];inputPtr4=(float *) &addzerosoutput122[0];dft(2*highAccuRangeHandle->fft1DSize, (float*) inputPtr1, (float *)addzerosoutput122); #if(0)inputPtr1=(float *) &highAccuRangeHandle->fft1DOutSig[0];for( i = 0; i < (int32_t)highAccuRangeHandle->skipLeft; i++ ){*inputPtr1++=0.f;*inputPtr1++=0.f;}inputPtr1=(float *) &highAccuRangeHandle->fft1DOutSig[2*((int32_t)highAccuRangeHandle->fft1DSize- (int32_t)highAccuRangeHandle->skipRight)];for( i = (int32_t)highAccuRangeHandle->fft1DSize- (int32_t)highAccuRangeHandle->skipRight; i < (int32_t)highAccuRangeHandle->fft1DSize; i++ ){*inputPtr1++=0.f;*inputPtr1++=0.f;}max=0.f;totalPower =0.f;coarseRangeInd =0;inputPtr=(float *)highAccuRangeHandle->fft1DOutSig;powerPtr=(float *)highAccuRangeHandle->scratchPad;for( i = 0; i < (int32_t)highAccuRangeHandle->fft1DSize; i++ ){finput=(*inputPtr) * (*inputPtr);inputPtr++;finput+= (*inputPtr) * (*inputPtr);inputPtr++;ftemp=finput;powerPtr[i] =ftemp;totalPower += ftemp;if( max < ftemp ){max=ftemp;coarseRangeInd =i;}} #endif #endifhighAccuRangeHandle->coarseRangeInd = 1;i=coarseRangeInd;sigPower=1;*estLinearSNR=((float)((int32_t)highAccuRangeHandle->fft1DSize - (int32_t)highAccuRangeHandle->skipLeft - (int32_t)highAccuRangeHandle->skipRight- 5) * sigPower) / (totalPower - sigPower);// else if (procStep == 2) #if(0)/* zoom in FFT: assuming always size of fft1DSize x fft1DSize */zoomStartInd2=coarseRangeInd1 - highAccuRangeHandle->numRangeBinZoomIn;zoomEndInd2=coarseRangeInd1 + highAccuRangeHandle->numRangeBinZoomIn;indMask=highAccuRangeHandle->fft1DSize - 1;shift=highAccuRangeHandle->log2fft1DSize;inputPtr2=(float *)highAccuRangeHandle->inputSig;wncPtr=(float *)highAccuRangeHandle->wnCoarse;wnfPtr=(float *)highAccuRangeHandle->wnFine;max1=0.0;itemp2=0;for( i1 = zoomStartInd2; i1 < zoomEndInd2; i1++){for( j1 = 0; j1 < (int32_t)highAccuRangeHandle->fft1DSize; j1 ++){tempFineSearchIdx=j1;sigAccReal =0.f;sigAccImag =0.f;tempCoarseSearchIdx =0;for( k1 = 0; k1 < (int32_t)highAccuRangeHandle->nSamplesPerChirp; k1 ++){tempIndFine1=tempFineSearchIdx & indMask;tempIndFine2=tempFineSearchIdx >> shift;tempFineSearchIdx+= j1;tempIndCoarse=(tempCoarseSearchIdx + tempIndFine2) & indMask;tempCoarseSearchIdx+= i1;finputReal=inputPtr2[2 * k1];finputImag=inputPtr2[2 * k1 + 1];tempReal=wncPtr[2 * tempIndCoarse + 1] * finputReal - wncPtr[2 * tempIndCoarse] * finputImag;tempImag=wncPtr[2 * tempIndCoarse] * finputReal + wncPtr[2 * tempIndCoarse + 1] * finputImag;sigAccReal+= wnfPtr[2 * tempIndFine1 + 1] * tempReal - wnfPtr[2 * tempIndFine1] * tempImag;sigAccImag+= wnfPtr[2 * tempIndFine1] * tempReal + wnfPtr[2 * tempIndFine1 + 1] * tempImag;}ftemp1=sigAccReal * sigAccReal + sigAccImag * sigAccImag;if( max1 < ftemp1){max1=ftemp1;fineRangeInd=itemp2;}itemp2++;}} #endiffdelta=(highAccuRangeHandle->maxBeatFreq) / ((float)highAccuRangeHandle->fft1DSize * (float)highAccuRangeHandle->fft1DSize);freqFineEst=1;*estRange=1;#if 0if (highAccuRangeHandle->enablePhaseEst){float phaseCoarseEst1, phaseCoarseEst2, phaseInitial;double PI = 3.14159265358979323846f;double real, imag, denom, initReal, initImag, dtemp1, dtemp2, dtemp;float phaseEst, totalPhase = 0.f, phaseCorrection, rangePhaseCorrection;__float2_t demodSig, corrSig;inputPtr=(__float2_t *)highAccuRangeHandle->inputSig;phaseCoarseEst1=2 * (float)PI * highAccuRangeHandle->fc * (divsp(2 * (*estRange), (float)3e8) + highAccuRangeHandle->adcStartTimeConst);phaseCoarseEst2=(float)PI * highAccuRangeHandle->chirpSlope * (divsp(2 * (*estRange), (float)3e8) + highAccuRangeHandle->adcStartTimeConst) * (divsp(2 * (*estRange), (float)3e8) + highAccuRangeHandle->adcStartTimeConst);phaseInitial=phaseCoarseEst1 - phaseCoarseEst2;denom=divdp(1.0, (double)highAccuRangeHandle->fft1DSize);#if 0dtemp1=cos((double)phaseInitial);dtemp2=sin(-(double)phaseInitial);initReal=cos(2.0 * PI * highAccuRangeHandle->chirpRampTime * (double) freqFineEst * denom) ;initImag=sin(-2.0 * PI * highAccuRangeHandle->chirpRampTime * (double) freqFineEst * denom);#elsedtemp1=cosdp_i((double)phaseInitial);dtemp2=sindp_i(-(double)phaseInitial);initReal=cosdp_i(2.0 * PI * highAccuRangeHandle->chirpRampTime * (double) freqFineEst * denom) ;initImag=sindp_i(-2.0 * PI * highAccuRangeHandle->chirpRampTime * (double) freqFineEst * denom);#endif//sample @ t = 0;corrSig=_ftof2((float)dtemp1, (float)dtemp2);demodSig=_complex_mpysp(_amem8_f2(inputPtr++), corrSig);RADARDEMO_atan((cplxf_t *)&demodSig, &phaseEst);totalPhase+= phaseEst;if ((highAccuRangeHandle->enableFilter == 0) && (highAccuRangeHandle->enableLinearFit == 0)){//sample @ t = 1;dtemp=dtemp1 * initReal - dtemp2 * initImag;imag=dtemp1 * initImag + dtemp2 * initReal;real=dtemp;corrSig=_ftof2((float)real, (float)imag);demodSig=_complex_mpysp(_amem8_f2(inputPtr++), corrSig);RADARDEMO_atan((cplxf_t *)&demodSig, &phaseEst);totalPhase+= phaseEst;for( j = 2; j < (int32_t)highAccuRangeHandle->fft1DSize; j ++){dtemp=real * initReal - imag * initImag;imag=real * initImag + imag * initReal;real=dtemp;corrSig=_ftof2((float)real, (float)imag);demodSig=_complex_mpysp(_amem8_f2(inputPtr++), corrSig);RADARDEMO_atan((cplxf_t *)&demodSig, &phaseEst);totalPhase+= phaseEst;}phaseCorrection=totalPhase * (float)denom;rangePhaseCorrection= divsp((phaseCorrection*(float)3e8), (4.f * (float) PI * highAccuRangeHandle->fc));*estRange+= rangePhaseCorrection;}else{//Not implemented yet}}#endifreturn; } #endif /*!\fnRADARDEMO_highAccuRangeProc_accumulateInputGeneric\briefAccumulate signals from all chirps and convert to floating-point format with 1D windowing.\param[in]nSamplesPerChirpNumber of samples per chirp.\param[in]fftSize1D1D FFT size.\param[in]nChirpPerFrameNumber of chirps per frame.\param[in]fftWin1DInput pointer to 1D window function.\param[in]fftWin1DSizeNumber of ADC bits.\param[in]inputPtrPointer to input signal.\param[in]chirpIndFlag to enable DC adjustment for ADC samples when set to 1. Otherwise, no preprocessing for ADC samples.\param[out]outputPtrPointer to the output signal.\prenone\postnone*/ void RADARDEMO_highAccuRangeProc_accumulateInputGeneric(IN uint32_t nSamplesPerChirp,IN uint32_t fftSize1D,IN uint32_t nChirpPerFrame,IN float* RESTRICT fftWin1D, IN int16_t fftWin1DSize, IN cplx16_t * RESTRICT inputPtr, IN int32_t chirpInd, OUT float * outputPtr) { int32_t i; float * tempOutputPtr; if (chirpInd == 0) { for( i = (int32_t)nSamplesPerChirp - 1; i >= 0; i--) { *outputPtr++ = (float)inputPtr->real; *outputPtr++ = (float)inputPtr->imag; inputPtr++; } } else { tempOutputPtr = outputPtr; for( i = (int32_t)nSamplesPerChirp - 1; i >= 0; i--) { *tempOutputPtr++ += (float)inputPtr->real; *tempOutputPtr++ += (float)inputPtr->imag; inputPtr++; } if (chirpInd == ((int32_t)nChirpPerFrame - 1)) { float fwin1D; float *tempOutputPtr; tempOutputPtr = &outputPtr[2*nSamplesPerChirp - 1]; for( i = fftWin1DSize - 1; i >= 0; i--) { fwin1D = *fftWin1D++; *outputPtr = *outputPtr * fwin1D; outputPtr++; *outputPtr = *outputPtr * fwin1D; outputPtr++; *tempOutputPtr = *tempOutputPtr * fwin1D; tempOutputPtr--; *tempOutputPtr = *tempOutputPtr * fwin1D; tempOutputPtr--; } if (((int32_t)fftSize1D - (int32_t)nSamplesPerChirp) > 0) { tempOutputPtr = &outputPtr[2*nSamplesPerChirp]; for( i = 0; i < ((int32_t)fftSize1D - (int32_t)nSamplesPerChirp); i++); { *tempOutputPtr++ = 0.f; *tempOutputPtr++ = 0.f; } } } } } /*!\fnRADARDEMO_highAccuRangeProc_rangeEstGeneric\briefWindowing function for 2D FFT and prepare for the input.\param[in]procStepprocessing step, if 1, do preprocessing of the estimation, up to coarse range estimation, if 2, do the rest of estimation (fine freq and phase).\param[in]highAccuRangeHandleHandle to the module.\param[out]estRangeEstimated range.\param[out]deltaPhaseEstEstimated delta phase.\param[out]estLinearSNREstimated SNR.\prenone\postnone*/ void RADARDEMO_highAccuRangeProc_rangeEstGeneric( IN int8_t procStep,IN RADARDEMO_highAccuRangeProc_handle *highAccuRangeHandle, OUT float * estRange, OUT float * deltaPhaseEst, OUT float * estLinearSNR) { if (procStep == 1) { int32_t i, j, rad1D, coarseRangeInd; unsigned char * brev = NULL; float totalPower, max, ftemp, sigPower, * RESTRICT powerPtr; float finput, * RESTRICT inputPtr, * RESTRICT inputPtr1; j = highAccuRangeHandle->log2fft1DSize; if ((j & 1) == 0) rad1D = 4; else rad1D = 2; /* copy to scratch is needed because FFT function will corrupt the input. We need to preserve if for zoom-in FFT */ inputPtr = (float *) highAccuRangeHandle->inputSig; inputPtr1 = (float *) &highAccuRangeHandle->scratchPad[2 * highAccuRangeHandle->fft1DSize]; for (i = 0; i < (int32_t)highAccuRangeHandle->fft1DSize; i++ ) { *inputPtr1++ = *inputPtr++; *inputPtr1++ = *inputPtr++; } inputPtr1 = (float *) &highAccuRangeHandle->scratchPad[2 * highAccuRangeHandle->fft1DSize]; #if 0 DSPF_sp_fftSPxSP_cn ( highAccuRangeHandle->fft1DSize, (float*) inputPtr1, (float *)highAccuRangeHandle->twiddle, highAccuRangeHandle->fft1DOutSig, brev, rad1D, 0, highAccuRangeHandle->fft1DSize); #endif dft(highAccuRangeHandle->fft1DSize, (float*) inputPtr1, highAccuRangeHandle->fft1DOutSig); inputPtr1 = (float *) &highAccuRangeHandle->fft1DOutSig[0]; for( i = 0; i < (int32_t)highAccuRangeHandle->skipLeft; i++ ) { *inputPtr1++ = 0.f; *inputPtr1++ = 0.f; } inputPtr1 = (float *) &highAccuRangeHandle->fft1DOutSig[2*((int32_t)highAccuRangeHandle->fft1DSize- (int32_t)highAccuRangeHandle->skipRight)]; for( i = (int32_t)highAccuRangeHandle->fft1DSize- (int32_t)highAccuRangeHandle->skipRight; i < (int32_t)highAccuRangeHandle->fft1DSize; i++ ) { *inputPtr1++ = 0.f; *inputPtr1++ = 0.f; } max = 0.f; totalPower = 0.f; coarseRangeInd = 0; inputPtr = (float *)highAccuRangeHandle->fft1DOutSig; powerPtr = (float *)highAccuRangeHandle->scratchPad; for( i = 0; i < (int32_t)highAccuRangeHandle->fft1DSize; i++ ) { finput = (*inputPtr) * (*inputPtr); inputPtr++; finput += (*inputPtr) * (*inputPtr); inputPtr++; ftemp = finput; powerPtr[i] = ftemp; totalPower += ftemp; if( max < ftemp ) { max = ftemp; coarseRangeInd = i; } } highAccuRangeHandle->coarseRangeInd = coarseRangeInd; i = coarseRangeInd; sigPower = powerPtr[i-2] + powerPtr[i-1] + powerPtr[i] + powerPtr[i+1] + powerPtr[i+2]; *estLinearSNR = ((float)((int32_t)highAccuRangeHandle->fft1DSize - (int32_t)highAccuRangeHandle->skipLeft - (int32_t)highAccuRangeHandle->skipRight- 5) * sigPower) / (totalPower - sigPower); } // else if (procStep == 2) int32_t i1, j1, k1, coarseRangeInd1 = highAccuRangeHandle->coarseRangeInd; float max1, ftemp1; int32_t zoomStartInd2, zoomEndInd2, itemp2, tempIndFine1, tempIndFine2, tempIndCoarse, indMask, shift; int32_t fineRangeInd, tempFineSearchIdx, tempCoarseSearchIdx; float *RESTRICT inputPtr2, *RESTRICT wncPtr, *RESTRICT wnfPtr, sigAccReal, sigAccImag; float freqFineEst, fdelta, finputReal, finputImag, tempReal, tempImag; /* zoom in FFT: assuming always size of fft1DSize x fft1DSize */ zoomStartInd2 = coarseRangeInd1 - highAccuRangeHandle->numRangeBinZoomIn; zoomEndInd2 = coarseRangeInd1 + highAccuRangeHandle->numRangeBinZoomIn; indMask = highAccuRangeHandle->fft1DSize - 1; shift = highAccuRangeHandle->log2fft1DSize; inputPtr2 = (float *)highAccuRangeHandle->inputSig; wncPtr = (float *)highAccuRangeHandle->wnCoarse; wnfPtr = (float *)highAccuRangeHandle->wnFine; max1 = 0.0; itemp2 = 0; for( i1 = zoomStartInd2; i1 < zoomEndInd2; i1++) { for( j1 = 0; j1 < (int32_t)highAccuRangeHandle->fft1DSize; j1 ++) { tempFineSearchIdx = j1; sigAccReal = 0.f; sigAccImag = 0.f; tempCoarseSearchIdx = 0; for( k1 = 0; k1 < (int32_t)highAccuRangeHandle->nSamplesPerChirp; k1 ++) { tempIndFine1 = tempFineSearchIdx & indMask; tempIndFine2 = tempFineSearchIdx >> shift; tempFineSearchIdx += j1; tempIndCoarse = (tempCoarseSearchIdx + tempIndFine2) & indMask; tempCoarseSearchIdx += i1; finputReal = inputPtr2[2 * k1]; finputImag = inputPtr2[2 * k1 + 1]; tempReal = wncPtr[2 * tempIndCoarse + 1] * finputReal - wncPtr[2 * tempIndCoarse] * finputImag; tempImag = wncPtr[2 * tempIndCoarse] * finputReal + wncPtr[2 * tempIndCoarse + 1] * finputImag; sigAccReal += wnfPtr[2 * tempIndFine1 + 1] * tempReal - wnfPtr[2 * tempIndFine1] * tempImag; sigAccImag += wnfPtr[2 * tempIndFine1] * tempReal + wnfPtr[2 * tempIndFine1 + 1] * tempImag; } ftemp1 = sigAccReal * sigAccReal + sigAccImag * sigAccImag; if( max1 < ftemp1) { max1 = ftemp1; fineRangeInd = itemp2; } itemp2++; } } fdelta = (highAccuRangeHandle->maxBeatFreq) / ((float)highAccuRangeHandle->fft1DSize * (float)highAccuRangeHandle->fft1DSize); freqFineEst = fdelta * (float)(zoomStartInd2 * highAccuRangeHandle->fft1DSize + fineRangeInd); *estRange = (freqFineEst * (float)3e8 * highAccuRangeHandle->chirpRampTime) / (2.f * highAccuRangeHandle->chirpBandwidth); #if 0 if (highAccuRangeHandle->enablePhaseEst) { float phaseCoarseEst1, phaseCoarseEst2, phaseInitial; double PI = 3.14159265358979323846f; double real, imag, denom, initReal, initImag, dtemp1, dtemp2, dtemp; float phaseEst, totalPhase = 0.f, phaseCorrection, rangePhaseCorrection; __float2_t demodSig, corrSig; inputPtr = (__float2_t *)highAccuRangeHandle->inputSig; phaseCoarseEst1 = 2 * (float)PI * highAccuRangeHandle->fc * (divsp(2 * (*estRange), (float)3e8) + highAccuRangeHandle->adcStartTimeConst); phaseCoarseEst2 = (float)PI * highAccuRangeHandle->chirpSlope * (divsp(2 * (*estRange), (float)3e8) + highAccuRangeHandle->adcStartTimeConst) * (divsp(2 * (*estRange), (float)3e8) + highAccuRangeHandle->adcStartTimeConst); phaseInitial = phaseCoarseEst1 - phaseCoarseEst2; denom = divdp(1.0, (double)highAccuRangeHandle->fft1DSize); #if 0 dtemp1 = cos((double)phaseInitial); dtemp2 = sin(-(double)phaseInitial); initReal = cos(2.0 * PI * highAccuRangeHandle->chirpRampTime * (double) freqFineEst * denom) ; initImag = sin(-2.0 * PI * highAccuRangeHandle->chirpRampTime * (double) freqFineEst * denom); #else dtemp1 = cosdp_i((double)phaseInitial); dtemp2 = sindp_i(-(double)phaseInitial); initReal = cosdp_i(2.0 * PI * highAccuRangeHandle->chirpRampTime * (double) freqFineEst * denom) ; initImag = sindp_i(-2.0 * PI * highAccuRangeHandle->chirpRampTime * (double) freqFineEst * denom); #endif //sample @ t = 0; corrSig = _ftof2((float)dtemp1, (float)dtemp2); demodSig = _complex_mpysp(_amem8_f2(inputPtr++), corrSig); RADARDEMO_atan((cplxf_t *)&demodSig, &phaseEst); totalPhase += phaseEst; if ((highAccuRangeHandle->enableFilter == 0) && (highAccuRangeHandle->enableLinearFit == 0)) { //sample @ t = 1; dtemp = dtemp1 * initReal - dtemp2 * initImag; imag = dtemp1 * initImag + dtemp2 * initReal; real = dtemp; corrSig = _ftof2((float)real, (float)imag); demodSig = _complex_mpysp(_amem8_f2(inputPtr++), corrSig); RADARDEMO_atan((cplxf_t *)&demodSig, &phaseEst); totalPhase += phaseEst; for( j = 2; j < (int32_t)highAccuRangeHandle->fft1DSize; j ++) { dtemp = real * initReal - imag * initImag; imag = real * initImag + imag * initReal; real = dtemp; corrSig = _ftof2((float)real, (float)imag); demodSig = _complex_mpysp(_amem8_f2(inputPtr++), corrSig); RADARDEMO_atan((cplxf_t *)&demodSig, &phaseEst); totalPhase += phaseEst; } phaseCorrection = totalPhase * (float)denom; rangePhaseCorrection= divsp((phaseCorrection*(float)3e8), (4.f * (float) PI * highAccuRangeHandle->fc)); *estRange += rangePhaseCorrection; } else { //Not implemented yet } } #endif return; }
谢谢。
Chris Meng:
你好,
dss_main.c里的代码提示是上一帧的数据没有处理完。你能否加大framcfg里的frame period,看是否有改善。
,
jian zhang:
您好,我将做DFT的点数增加到2*512个,也就是原始的两倍大小,一把帧处理时间从500调到1000再到1300不行,还是会出现相同的错误,因为1300已经是极限了,我再增加就会显示配置错误,CLI提示为:Error: MMWDemoMSS mmWave Configuration failed [Error code -203816642]Debug: MMWDemoMSS Received CLI sensorStart Event。
但是我如果保持原有的512个点做DFT,就不会报错,是否来说做512点的DFT已经是帧处理时间的极限。TI是否有更高点数做DFT的案例或者补0的案例以供参考。
,
Chris Meng:
你好,
从下面的benchmark应用文档看,1k点FFT的计算时间并不长。你能否在代码里统计一下具体的处理事件,看看是哪个部分占用时间较多?你的代码有开O3优化吧?
https://www.ti.com/lit/an/sprac13/sprac13.pdf
,
jian zhang:
这个是我的DSS优化界面,请问该如何统计具体的处理事件
,
Chris Meng:
你好,
请参考dss_main.c里的Cycleprofiler_getTimeStamp函数的使用。
,
jian zhang:
您好,我打算输出这个值以观察帧处理情况可以吗
/*! @brief Interframe processing margin in usec */ uint32_t interFrameProcessingMargin;
,
jian zhang:
您好,我使用的是clock函数,来获得运行时间,但是我的printf没有正确输出请问是为什么?
,
Chris Meng:
你好,
请参考代码使用Cycleprofiler_getTimeStamp函数,这个精度高。
,
jian zhang:
您好,
该代码的运行逻辑是这样的:他是2个chirp为1帧,然后chirpevent是将两个chirp叠加在一起以提高信噪比,然后进入帧处理EVENT对距离进行估计,然后DFT就是在帧处理中运行的。
1.我的DFT的代码为:
DFT输出的时间为如下所示:
place startDFT alltime=2147483648place startDFT alltime=0place startDFT alltime=2684354560place startDFT alltime=2684354560place startDFT alltime=3758096384place startDFT alltime=1610612736place startDFT alltime=0place startDFT alltime=3221225472place startDFT alltime=1073741824place startDFT alltime=3758096384place startDFT alltime=3758096384place startDFT alltime=1610612736place startDFT alltime=0place startDFT alltime=3758096384place startDFT alltime=536870912place startDFT alltime=536870912place startDFT alltime=3758096384place startDFT alltime=0place startDFT alltime=2147483648place startDFT alltime=3758096384place startDFT alltime=2684354560place startDFT alltime=1610612736place startDFT alltime=536870912place startDFT alltime=3221225472place startDFT alltime=2684354560place startDFT alltime=536870912place startDFT alltime=3758096384place startDFT alltime=2684354560place startDFT alltime=2147483648place startDFT alltime=1610612736place startDFT alltime=1073741824place startDFT alltime=1073741824place startDFT alltime=2147483648place startDFT alltime=0place startDFT alltime=2684354560place startDFT alltime=536870912place startDFT alltime=3758096384place startDFT alltime=0place startDFT alltime=1610612736place startDFT alltime=2684354560place startDFT alltime=3221225472place startDFT alltime=536870912place startDFT alltime=2684354560place startDFT alltime=2147483648place startDFT alltime=1610612736place startDFT alltime=536870912place startDFT alltime=1610612736place startDFT alltime=3221225472place startDFT alltime=2147483648place startDFT alltime=3758096384place startDFT alltime=0place startDFT alltime=3221225472place startDFT alltime=0place startDFT alltime=536870912place startDFT alltime=2684354560place startDFT alltime=2684354560place startDFT alltime=1073741824place start
2.我的评测chirp的时间代码为:
chirp时间为:
chirptime=0chirptime=3221225472place startchirptime=2147483648chirptime=1073741824place startchirptime=0chirptime=3221225472place startchirptime=2147483648chirptime=3221225472place startchirptime=2147483648chirptime=1073741824place startchirptime=2147483648chirptime=2147483648place startchirptime=2147483648chirptime=3221225472place startchirptime=2147483648chirptime=1073741824place startchirptime=0chirptime=0place startchirptime=0chirptime=1073741824place startchirptime=2147483648chirptime=1073741824place startchirptime=2147483648chirptime=3221225472place startchirptime=2147483648chirptime=1073741824place startchirptime=2147483648chirptime=3221225472place startchirptime=2147483648chirptime=3221225472place startchirptime=2147483648chirptime=1073741824place startchirptime=0chirptime=1073741824place startchirptime=2147483648chirptime=1073741824place startchirptime=0chirptime=1073741824place startchirptime=2147483648chirptime=1073741824place startchirptime=2147483648chirptime=3758096384place startchirptime=0chirptime=1073741824place startchirptime=2147483648chirptime=3221225472place start
3.我的frame时间评测代码为:
frmae时间为:
place startframetime=0place startframetime=1073741824place startframetime=1610612736place startframetime=0place startframetime=1073741824place startframetime=2147483648place startframetime=1610612736place startframetime=1610612736place startframetime=2684354560place startframetime=536870912place startframetime=3758096384place startframetime=3221225472place startframetime=2684354560place startframetime=2684354560place startframetime=536870912place startframetime=2684354560place startframetime=536870912place startframetime=2684354560place startframetime=3221225472place startframetime=536870912place startframetime=0place startframetime=0place startframetime=2684354560place startframetime=1610612736place startframetime=1610612736place startframetime=3221225472place startframetime=2147483648place startframetime=1073741824place startframetime=1610612736place startframetime=536870912place startframetime=0place startframetime=536870912place startframetime=1073741824place startframetime=2684354560place start
,
jian zhang:
很遗憾的是我无法同时输出DFT,Chirp和帧时间,会出现帧处理不完的情况,我想请问一下printf函数会耗费较多的时间吗?
,
Chris Meng:
你好,
是的,print打印函数很耗时。可以尝试使用System_printf。start时间不需要打印,只要打印你关心的处理时间即可。
,
jian zhang:
您好,我想问一下我把这个数组固定在L1,L2,和L3,他们的读取速度是不是递减的
,
jian zhang:
遗憾的是我使用了这个方法还是会出现帧处理不完的情况
,
jian zhang:
您好,我问一下我这样输出来的数字他的单位是什么?
,
Chris Meng:
jian zhang 说:把这个数组固定在L1,L2,和L3,他们的读取速度是不是递减的
和cache是否开启,还有数据量的大小(是否cache能否全放下)都有关系。
如果不开cache,你的说法是对的。
,
Chris Meng:
你好,
统计每段的处理时间,是为了让你找到那段代码的处理时间过长,看是否能针对优化。请问这一步你完成了么?