📄 main.c
字号:
// Example C usage of fft16
#include <stdio.h>
#include <sysreg.h>
#include <builtins.h>
#include <math.h>
#include "FFTDef.h"
#include <filter.h>
#define pi 3.1415926
section ("input")
#if N==64
int input[N] = {
#include "inputs/input64.dat"
};
#elif N==128
int input[N] = {
#include "inputs/input128.dat"
};
#elif N==256
int input[N] = {
#include "inputs/input256.dat"
};
#elif N==512
int input[N] = {
#include "inputs/input512.dat"
};
#elif N==1024
int input[N] = {
#include "inputs/input1024.dat"
};
#elif N==2048
int input[N] = {
#include "inputs/input2048.dat"
};
#elif N==4096
int input[N] = {
#include "inputs/input4096.dat"
};
#elif N==8192
int input[N] = {
#include "inputs/input8192.dat"
};
#elif N==16384
int input[N] = {
#include "inputs/input16384.dat"
};
#elif N==32768
int input[N] = {
#include "inputs/input32768.dat"
};
#endif
#ifdef initialization_error
int input[N];
#endif
#pragma align 4
section ("int_buff") int
int_buff[N];
volatile int
tmp_i0,
tmp_i1;
float twiddle_table[1024]={
#include "inputs/twiddle_1024.dat"
};
complex_float twiddle[512] = {
#include "inputs/twiddle_1024.dat"
};
//*********************************** main ********************************************
void main( void )
{
int index;
/*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
#ifdef initialization_error
printf("ERROR: This FFT function works only in the following conditions:\n");
printf("N must be a power of 2 and 64<=N<=32768\n");
printf("Please change the settings in the file FFTDef.h\n");
#else
tmp_i0 = __builtin_sysreg_read( __CCNT0 ); // read initial cycle count
/*
for(index=0;index<512;index++)
{
twiddle_table[2*index]=cos(2*pi*index/1024);
twiddle_table[2*index+1]=sin(2*pi*index/1024);
}
*/
FFT16(&(input), &(int_buff), N, log2_N);
tmp_i1 = __builtin_sysreg_read( __CCNT0 ); // read final cycle count
//Atention! This cycle count includes also the code used to push and pop r24:31
//at the beginning and at the end of the fft routine (totally 51 cycles)
printf("cycle count = %d\n", tmp_i1 - tmp_i0); // print the cycle count
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -