TI中文支持网
TI专业的中文技术问题搜集分享网站

AWR1843BOOST: FFT函数使用失败

Part Number:AWR1843BOOST

我使用的是demo是levelsense,我想把adc采样数据补0然后做fft。adc采样点我修改了64点,我补0到512点,然后对其进行FFT,我想着只需要修改其twiddle,就可以。我将附上没有修改前的代码和我修改后的代码,还有consolo报错日志。

1.修改前的代码:(twiddle初始化+使用FFT函数)

	handle->twiddle			=	(float *)radarOsal_memAlloc((uint8_t) RADARMEMOSAL_HEAPTYPE_LL2, 0, 2 * handle->fft1DSize * sizeof(float), 8);
	if (handle->twiddle == NULL)
	{
		*errorCode	=	RADARDEMO_HIGHACCURANGEPROC_FAIL_ALLOCATE_LOCALINSTMEM;
		return (handle);
	}

	tw_gen_float(handle->twiddle, handle->fft1DSize);

void	RADARDEMO_highAccuRangeProc_rangeEst(IN  RADARDEMO_highAccuRangeProc_handle *highAccuRangeHandle,
							OUT  float * estRange,
							OUT  float * estRange1,
							OUT  float * estRange2,
							OUT  float * deltaPhaseEst,
							OUT float * estLinearSNR)
{
	int32_t			i, j, k, rad1D, coarseRangeInd;
	unsigned char	* brev = NULL;
	float			totalPower, max, ftemp, sigPower, * RESTRICT powerPtr;
	__float2_t		f2input, * RESTRICT inputPtr, * RESTRICT inputPtr1;

	int32_t			zoomStartInd, zoomEndInd, itemp, tempIndFine1, tempIndFine2, tempIndCoarse, indMask, shift;
	int32_t			fineRangeInd, tempFineSearchIdx, tempCoarseSearchIdx;
	__float2_t		*RESTRICT wncPtr, wncoarse, *RESTRICT wnfPtr, wnfine1, sigAcc, f2temp;
	double			freqFineEst, fdelta, interpIndx;
	floatcurrP, prevP, maxPrevP, maxNextP;

	j  = 30 - _norm(highAccuRangeHandle->fft1DSize);
	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	=	(__float2_t *) highAccuRangeHandle->inputSig;
	inputPtr1	=	(__float2_t *) &highAccuRangeHandle->scratchPad[2 * highAccuRangeHandle->fft1DSize];
	for (i = 0; i < (int32_t)highAccuRangeHandle->fft1DSize; i++ )
	{
		f2input					=	_amem8_f2(inputPtr);
		_amem8_f2(inputPtr1++)	=	f2input;
		_amem8_f2(inputPtr)=	_ftof2(_lof2(f2input), _hif2(f2input));
		inputPtr++;
	}

	/* Do 1D FFT*/
	inputPtr1	=	(__float2_t *) &highAccuRangeHandle->scratchPad[2 * highAccuRangeHandle->fft1DSize];
	DSPF_sp_fftSPxSP (
			highAccuRangeHandle->fft1DSize,
			(float*) inputPtr1,
			(float *)highAccuRangeHandle->twiddle, 
			highAccuRangeHandle->fft1DOutSig,
			brev,
			rad1D,
			0,
			highAccuRangeHandle->fft1DSize);

2.修改后的代码:(twiddle初始化+使用FFT函数)

handle->twiddle			=	(float *)radarOsal_memAlloc((uint8_t) RADARMEMOSAL_HEAPTYPE_LL2, 0, 2 * 512 * sizeof(float), 8);
	if (handle->twiddle == NULL)
	{
		*errorCode	=	RADARDEMO_HIGHACCURANGEPROC_FAIL_ALLOCATE_LOCALINSTMEM;
		return (handle);
	}

	tw_gen_float(handle->twiddle, 512);

extern cplx16_t fftinput[512*10];

extern cplx16_t fftoutput[512*10];
extern int16_t* doptwi;
void	RADARDEMO_highAccuRangeProc_rangeEst(IN  RADARDEMO_highAccuRangeProc_handle *highAccuRangeHandle,
							OUT  float * estRange,
							OUT  float * estRange1,
							OUT  float * estRange2,
							OUT  float * deltaPhaseEst,
							OUT float * estLinearSNR)
{
	int32_t			i, j, k, rad1D, coarseRangeInd;
	unsigned char	* brev = NULL;
	float			totalPower, max, ftemp, sigPower, * RESTRICT powerPtr;
	__float2_t		f2input, * RESTRICT inputPtr, * RESTRICT inputPtr1;

	int32_t			zoomStartInd, zoomEndInd, itemp, tempIndFine1, tempIndFine2, tempIndCoarse, indMask, shift;
	int32_t			fineRangeInd, tempFineSearchIdx, tempCoarseSearchIdx;
	__float2_t		*RESTRICT wncPtr, wncoarse, *RESTRICT wnfPtr, wnfine1, sigAcc, f2temp;
	double			freqFineEst, fdelta, interpIndx;
	floatcurrP, prevP, maxPrevP, maxNextP;

	j  = 30 - _norm(512);
	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	=	(__float2_t *) highAccuRangeHandle->inputSig;
	inputPtr1	=	(__float2_t *) &highAccuRangeHandle->scratchPad[2 * highAccuRangeHandle->fft1DSize];
	for (i = 0; i < (int32_t)highAccuRangeHandle->fft1DSize; i++ )
	{
		f2input					=	_amem8_f2(inputPtr);
		_amem8_f2(inputPtr1++)	=	f2input;
		_amem8_f2(inputPtr)=	_ftof2(_lof2(f2input), _hif2(f2input));
		inputPtr++;
	}
int tempfft1dsize=highAccuRangeHandle->fft1DSize;

	highAccuRangeHandle->fft1DSize=512;
	/* Do 1D FFT*/cplx16_t inputtest[512];
	//inputPtr1	=	(__float2_t *) &highAccuRangeHandle->scratchPad[2 * highAccuRangeHandle->fft1DSize];
	
	for(j=0;j<10;j++)
	{for(k=0;k<512;k++){inputtest[k]=fftinput[j*512+k];//我的测试数据,类型为复数}DSPF_sp_fftSPxSP ((int)512,(float*) inputtest,(float *)highAccuRangeHandle->twiddle,(float*)&fftoutput[j*512],//测试输出位置brev,rad1D,0,highAccuRangeHandle->fft1DSize);

	}

3.consolo报错

Debug: MMWDemoMSS Launched the Initialization Task
Debug: MMWDemoMSS mmWave Control Initialization was successful
[C674X_0] Debug: MMWDemoDSS ADCBUF Instance(0) @0080fdb0 has been opened successfully
Debug: MMWDemoDSS Data Path init succeeded
[Cortex_R4_0] Debug: CLI is operational
[C674X_0] Debug: MMWDemoDSS initTask exit
[Cortex_R4_0] numRangeBinZoomIn=2,left=0,right=0
enableRangeLimit=1,skipMin=1.000000,skipMax=3.000000
Debug: MMWDemoMSS Received CLI sensorStart Event
Debug: System Heap (TCM): Size: 65536, Used = 33376, Free = 32160 bytes
Debug: MMWDemoMSS mmWave  config succeeded 
[C674X_0] DSS:enableRangeLimit=1,skipMin=1.00,skipMax=3.00,rangeResolution=0.0586,skipLeft=17,skipRight=13
DDR Heap : size 65536 (0x10000), used 8248 (0x2038)
LL2 Heap : size 20480 (0x5000), used 7868 (0x1ebc)
LL2 Scratch : size 8192 (0x2000), used 1024 (0x400)
LL1 Scratch : size 16384 (0x4000), used 4096 (0x1000)
HSRAM Heap : size 8192 (0x2000), used 0 (0x0)
A0=0xffffffff A1=0x3d7c92b6
A2=0x80fb0c A3=0xe018bc
A4=0x7efe50 A5=0x0
A6=0x0 A7=0x7fffffff
A8=0x7fffffff A9=0x7f1bd4
A10=0x7fce24 A11=0x80f418
A10=0x7fce24 A11=0x80f418
{module#8}: "../dss/dss_main.c", line 200: error {id:0x10000, args:[0x80e16c, 0x80e16c]}
xdc.runtime.Error.raise: terminating execution
[Cortex_R4_0] xdc.runtime.Main: "../mss/mss_main.c", line 990: assertion failure
xdc.runtime.Error.raise: terminating execution

jian zhang:

我尝试把输出的数组设置在执行FFT的函数内,其代码和报错如下,希望能够有所参考

 cplx16_t inputtest[512];     cplx16_t outputtest[512];    //inputPtr1    =    (__float2_t *) &highAccuRangeHandle->scratchPad[2 * highAccuRangeHandle->fft1DSize];    for(j=0;j<10;j++)    {        for(k=0;k<512;k++)            {                inputtest[k]=fftinput[j*512+k];//我的测试数据,类型为复数            }        DSPF_sp_fftSPxSP (                    (int)512,                    (float*) inputtest,                    (float*)highAccuRangeHandle->twiddle,                    (float*)outputtest,//测试输出位置                    brev,                    rad1D,                    0,                    highAccuRangeHandle->fft1DSize);    }

报错:Debug: MMWDemoMSS Launched the Initialization Task[C674X_0] Debug: MMWDemoDSS ADCBUF Instance(0) @0080fdb0 has been opened successfullyDebug: MMWDemoDSS Data Path init succeededDebug: MMWDemoDSS initTask exit[Cortex_R4_0] Debug: MMWDemoMSS mmWave Control Initialization was successfulDebug: CLI is operationalnumRangeBinZoomIn=2,left=0,right=0enableRangeLimit=1,skipMin=1.000000,skipMax=3.000000Debug: MMWDemoMSS Received CLI sensorStart EventDebug: System Heap (TCM): Size: 65536, Used = 33376, Free = 32160 bytesDebug: MMWDemoMSS mmWave  config succeeded [C674X_0] DSS:enableRangeLimit=1,skipMin=1.00,skipMax=3.00,rangeResolution=0.0586,skipLeft=17,skipRight=13DDR Heap : size 65536 (0x10000), used 8248 (0x2038)LL2 Heap : size 20480 (0x5000), used 7868 (0x1ebc)LL2 Scratch : size 8192 (0x2000), used 1024 (0x400)LL1 Scratch : size 16384 (0x4000), used 4096 (0x1000)HSRAM Heap : size 8192 (0x2000), used 0 (0x0){module#8}: "../dss/dss_main.c", line 200: error {id:0x10000, args:[0x80e16c, 0x80e16c]}xdc.runtime.Error.raise: terminating execution[Cortex_R4_0] xdc.runtime.Main: "../mss/mss_main.c", line 990: assertion failurexdc.runtime.Error.raise: terminating execution

,

Cherry Zhou:

您好,我们已收到您的问题并升级到英文论坛寻求帮助,如有答复将尽快回复您。谢谢!

,

Cherry Zhou:

您好,

当您follow到错误来源:

{module#8}: "../dss/dss_main.c", line 200: error {id:0x10000, args:[0x80e16c, 0x80e16c]}

此处给您的信息是什么?

然后跟您确认下,您是用64个数据点,然后用512 – 64 = 448补0填充该数据点,用来获取512点 FFT。 对吗? FFT 大小应为2的幂。

,

jian zhang:

是的,我是采用新建512大小的数组,然后把数组置0,然后把前64个点覆盖到前64个元素,然后送入FFT

,

Cherry Zhou:

好的了解。

,

Cherry Zhou:

请问您是怎样在修改后的代码中分配 fftinput的? 

赞(0)
未经允许不得转载:TI中文支持网 » AWR1843BOOST: FFT函数使用失败
分享到: 更多 (0)