📄 main.c
字号:
// Example C usage of fft_flp32
//************************* Includes ************************************
#include <stdio.h>
#include <sysreg.h>
#include <builtins.h>
#include "FFTDef.h"
//************************* Externs *************************************
extern FFT32( float (*)[], float (*)[], float (*)[], float (*)[], int );
extern init();
#pragma align 4
section ("data1ab")
float output[outbuff_size];
#if N==32
float input[2*N] = {
#include "inputs/input64.dat"
};
#elif N==64
float input[2*N] = {
#include "inputs/input128.dat"
};
#elif N==128
float input[2*N] = {
#include "inputs/input256.dat"
};
#elif N==256
float input[2*N] = {
#include "inputs/input512.dat"
};
#elif N==512
float input[2*N] = {
#include "inputs/input1024.dat"
};
#elif N==1024
float input[2*N] = {
#include "inputs/input2048.dat"
};
#elif N==2048
float input[2*N] = {
#include "inputs/input4096.dat"
};
#elif N==4096
float input[2*N] = {
#include "inputs/input8192.dat"
};
#elif N==8192
float input[2*N] = {
#include "inputs/input16384.dat"
};
#elif N==16384
#ifdef __ADSPTS201__
float input[2*N] = {
#include "inputs/input32768.dat"
};
#endif
#endif
#ifdef initialization_error
float input[16384];
#endif
#pragma align 4
section ("data2ab")
float ping_pong_buffer1[outbuff_size];
#pragma align 4
section ("data3ab")
float ping_pong_buffer2[outbuff_size];
volatile int
i,
tmp_i0,
tmp_i1;
//*********************************** main ********************************************
void main( void )
{
#ifdef initialization_error
printf("ERROR: This FFT function works only in the following conditions:\n");
printf(" -N must be a power of 2\n");
#ifdef __ADSPTS201__
printf(" -for complex inputs, 32<=N<=16384\n");
#else
printf(" -for complex inputs, 32<=N<=4096\n");
#endif
printf("Please change the settings in the file FFTDef.h\n");
#else
/*in the case of TS201, at the beginning of the program the
cache must be enabled. The procedure is contained in the
cache_enable macro that uses the refresh rate as input parameter
-if CCLK=500MHz, refresh_rate=750
-if CCLK=400MHz, refresh_rate=600
-if CCLK=300MHz, refresh_rate=450
-if CCLK=250MHz, refresh_rate=375
*/
#ifdef __ADSPTS201__
asm("#include <defts201.h>");
asm("#include <cache_macros.h>" );
asm("cache_enable(750);");
asm("#include <ini_cache.h>");
asm("#include <fftdef.h>");
asm("preload_cache;");
#endif
tmp_i0 = __builtin_sysreg_read( __CCNT0 ); // read initial cycle count
FFT32(&(input), &(ping_pong_buffer1), &(ping_pong_buffer2), &(output), N);
tmp_i1 = __builtin_sysreg_read( __CCNT0 ); // read final cycle count
printf("cycle count = %d", tmp_i1 - tmp_i0); // print the cycle count
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -