📄 test_cfft.c
字号:
/* test_cfft.c
*
* Example of the FFT routine from the Blackfin DSP library
*
* Results in the output buffer "out"
*
* See the documentation for more info on the DSP routines
*
*/
#include <fract.h>
#include <complex.h>
#include <filter.h>
#include <flt2fr.h>
#include <stdio.h>
#define VEC_SIZE 64 // length of the input vector
// input
float infile[VEC_SIZE] =
{
#include "in.dat"
};
#pragma align 256
complex_fract16 in[VEC_SIZE];
//output
#pragma align 4
complex_fract16 out[VEC_SIZE];
//twiddle factors
#pragma align 4
complex_fract16 twid[(3*VEC_SIZE)/4];
void main(void) {
int i;
FILE *fp;
if((fp = fopen("out.dat", "w")) == NULL)
{
printf("Cannot open output file.\n");
exit(1);
}
for(i=0;i<VEC_SIZE;i++)
{
in[i].re = float_to_fract16(infile[i]);
in[i].im = 0;
}
// calculate twiddle factors
twidfftf_fr16(twid,VEC_SIZE);
// call to the DSP library
cfftf_fr16(in, out, twid, 1, VEC_SIZE);
for(i=0;i<VEC_SIZE;i++)
fprintf(fp, "%f\t+\t%f i\n", fract16_to_float(out[i].re), fract16_to_float(out[i].im));
fclose(fp);
printf("FFT completed successfully.");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -