很简单的问题,求指导:
我们产生一个sin函数,想对它做fft得到频谱
但产生的时域波形和频域波形都不对,是cmd文件有错?
还是sin函数不能直接生成,需要外部数据导入?
还是数据的long,int类型不对?
c文件如下:
#include "fft.h"
#define PI 3.141592653
#define N 128
#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag, "FFTmag");
CFFT32 fft=CFFT32_128P_DEFAULTS;
long ipcb[2*N]; /* In place computation buffer */
long mag[N]; /* Magnitude buffer */
void MakeWave()
{
int i;
for(i=0;i<128;i++)
ipcb=(long)(0x2000*sin(PI*i*2*1000/16000));
}
void main()
{ /* FFT initialization */
fft.ipcbptr=ipcb; /* FFT computation buffer */
fft.magptr=mag; /* Store mag. square in separate buff */
fft.init(&fft); /* Twiddle factor pointer initialization */
/* Acquire samples in bit reversed order or Bit-reverse the in-order data using bit-rev utility */
/* FFT Computation */
MakeWave();
CFFT32_brev2(ipcb, ipcb, N);
fft.izero(&fft); /* Zero the imaginary part */
fft.calc(&fft); /* Compute the FFT */
fft.mag(&fft); /* Obtain the magnitude square */
}
cmd文件如下:
MEMORY
{
PAGE 0 : NVMEM : origin = 0x3f8000, length = 0x0F00
PAGE 1 : L0L1RAM : origin = 0x008000,length = 0x1000
}
SECTIONS
{
FFTipcb ALIGN(512) : {} > L0L1RAM PAGE 1
FFTmag > L0L1RAM PAGE 1
FFTtf > NVMEM PAGE 0 /* Non volatile memory */
.econst >NVMEM PAGE 0 /* Non volatile memory */
}