⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dft.c

📁 基于TS201 32-bit floating point DFT routine
💻 C
字号:
/* DFT.C - 	This program will calculate the dft of an input signal.  The input is assumed to be real. */
/* 32-bit floating point DFT routine */

#ifdef __ADSPTS201__
  #include <defts201.h>
#endif

#define N 64
#include "cache_macros.h"
#include <stdio.h>
float input[N] = {						/* Initialize Input data buffer */
	#include "test64.dat"
};

float sine[N] = {						/* Initialize sine buffer */
	#include "sin64.dat"
};

float pm real[N];						/* Initialize output buffers */
float pm imag[N];

main()
{
	
/*in the case of TS201, at the beginning of the program the
cache must be enabled. The procedure is contained in the
cache_enable macro that uses the refresh rate as input parameter
      -if CCLK=500MHz, refresh_rate=750
      -if CCLK=400MHz, refresh_rate=600
      -if CCLK=300MHz, refresh_rate=450
      -if CCLK=250MHz, refresh_rate=375
*/
#ifdef __ADSPTS201__
asm("                      \
    #include <defts201.h>  \
    #include cache_macros.h\
    cache_enable(750);     \
    #include <ini_cache.h> \
    #include <fftdef.h>;   \
    preload_cache;         \
  ");
#endif
	
	int n, k;

	for (k=0; k<N; k++)
	{
		real[k] = imag[k] = 0;
		for (n=0; n<N; n++)
		{
			real[k] = real[k] + input[n]*sine[(n*k+N/4)%N];
			imag[k] = imag[k] - input[n]*sine[(n*k)%N];
		}
	}


		printf("N:  (Real[N]) + j(Imaginary[N])\n");

	for (k=0; k<N; k++)
	{
		printf("%d:  (%f) + j(%f)\n",k,real[k],imag[k]);
	}
}		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -