|
用F28027调FFT,下面的我的程序。最后结果是i=6时,mag为峰值。(CMD的编辑略,而且应该没问题。)
这个结果应该是错的,大家帮忙看看问题出在哪里。
我用的是sin函数,_IQsinPU((2*pi*i)/128),可以看成是50HZ的信号,6400HZ的采样频率(或者1HZ信号128HZ的采样频率)。采样点数为128点。
还有28027的RAM非常有限,我能不能把程序烧录到FLASH中,然后用CCS仿真啊?
如果可以,怎么操作。谢谢。
mag (ipcb) (原文件名:mag.JPG)
#include "DSP2802x_Device.h" // DSP2802x Headerfile Include File
#include "DSP2802x_Examples.h" // DSP2802x Examples Include File
#include <stdio.h>
/* for test fft */
#include "fft.h"
#include "IQmathLib.h"
#include <stdlib.h>
#define N 128
#define pi 3.14159
#pragma DATA_SECTION(ipcb,"FFTipcb");
//#pragma DATA_SECTION(mag,"FFTmag");
RFFT32 fft=RFFT32_128P_DEFAULTS;
_iq29 temp[N];
float temp1[N/2+1];
long ipcb[N];
//long mag[N/2+1];
int i;
void main(void)
{
int *WatchdogWDCR1 = (void *) 0x7029;
InitSysCtrl();
// Disable the watchdog:
asm(" EALLOW ");
*WatchdogWDCR1 = 0x0068;
asm(" EDIS ");
DINT;
IER=0x0000;
IFR=0x0000;
for(i=0;i<N;i++)
{
temp=_IQsinPU(_IQ((2*pi*i)/128));
ipcb=2*_IQ29(_IQtoF(temp));
}
fft.ipcbptr=ipcb;
fft.magptr=ipcb;
fft.init(&fft);
RFFT32_brev(ipcb,ipcb,N);
//fft.win(&fft);
fft.calc(&fft);
fft.split(&fft);
fft.mag(&fft);
for(i=0;i<N/2;i++)
{
temp1=_IQ30toF(ipcb);
}
} |
|