在CCS上调用fft library进行fft计算时软件仿真的问题

paigechen 2012-02-21 04:28:44
很简单的问题,求指导:
我们产生一个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[i]=(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 */

}
...全文
365 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧