#include"DSP2833x_Device.h"
#include"DSP2833x_Examples.h"
#include"math.h"
#include"FPU.h"
#define PI 3.1415926
#define FFT_SIZE 1024
#define FFT_STAGES 10
#pragma DATA_SECTION(InBuffer,"DataBUF")
float32 InBuffer[FFT_SIZE];
#pragma DATA_SECTION(OutBuffer,"FFTBUF")
float32 OutBuffer[FFT_SIZE];
#pragma DATA_SECTION(TwiddleBuffer,"TwiddleBUF")
float32 TwiddleBuffer[FFT_SIZE];
#pragma DATA_SECTION(MagBuffer,"MagBUF")
float32 MagBuffer[FFT_SIZE];
#pragma DATA_SECTION(MagBuffer_all,"MagBUF")
float32 MagBuffer_all[FFT_SIZE];
RFFT_F32_STRUCT fft;
float32 amp=1.0;
float32 freq=257.0;
float32 fs=1024.0;
void main()
{
unsigned int i;
unsigned int j;
InitSysCtrl(); //
DINT;
InitPieCtrl(); //
IER=0x0000;
IFR=0x0000;
InitPieVectTable(); //
volatile float Signal[1024];
volatile float Max_Spec[1024];
//for(j=0;j<FFT_SIZE;j++)
//{
for(i=0;i<FFT_SIZE;i++)
{Signal[i]=amp*sin(2*PI*freq*i/fs);
InBuffer[i]=Signal[FFT_SIZE-i];
} //信号倒序
fft.InBuf = &InBuffer[0]; /* Input data buffer */
fft.OutBuf = &OutBuffer[0]; /* FFT output buffer */
fft.CosSinBuf = &TwiddleBuffer[0];/* Twiddle factor buffer */
fft.FFTSize = FFT_SIZE; /* FFT length */
fft.FFTStages = FFT_STAGES; /* FFT Stages */
fft.MagBuf = MagBuffer; /* Magnitude buffer */
RFFT_f32_sincostable(&fft); /* Initialize twiddle buffer */
RFFT_f32(&fft);
RFFT_f32_mag(&fft);}
此时MagBuffer存储了一些数据,但是其数值与MATLAB算出的频谱不相同!
求好心人、大神指点一下,谢谢。安装 了consultsuite但是没有找到rfft相关的文件,
user5306918:
不好意思,是controlsuite
Shine:
回复 user5306918:
2833x属于C2000系列,请到专门的C2000论坛咨询更快捷。
e2echina.ti.com/…/