刚开始在C6713上写fft程序,如下
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <DSPF_sp_cfftr2_dit.h>
//#include <utility.h>
# define PI 3.14159265358979323846
# define Numlength 32
void gen_w_r2(float* , int );
void bit_rev(float* , int );
void main()
{ int i;
float w[Numlength];
float Input[Numlength*2],Output[Numlength*2];
for(i=0;i<Numlength;i++) //输入Input
{ Input[2*i]=cos(PI*2*i/Numlength*3)*1024;
Input[2*i+1]=0;
}
gen_w_r2(w,Numlength); //产生旋转因子
// tw_genr2fft(w, Numlength); // 产生旋转因子
bit_rev(w,Numlength>>1); //把系数倒置,为下面函数输入准备
DSPF_sp_cfftr2_dit(Input,w,Numlength); ///计算该FFT,需要先调用上面两个函数
bit_rev(Input,Numlength); //输出是倒置的,所以重新倒置为正常
for(i=0;i<(Numlength*2);i++)
{
Output[i]=Input[i];
}
while(1);
}
void gen_w_r2(float* w, int n) { int i, j=1; float pi = 4.0*atan(1.0); float e = pi*2.0/n; for(j=1; j < n; j <<= 1) { for(i=0; i < ( n>>1 ); i += j) { *w++ = cos(i*e); *w++ = -sin(i*e); } } }void bit_rev(float* x, int n){ int i, j, k; float rtemp, itemp; j = 0; for(i=1; i < (n-1); i++) { k = n >> 1; while(k <= j) { j -= k; k >>= 1; } j += k; if(i < j) { rtemp = x[j*2]; x[j*2] = x[i*2]; x[i*2] = rtemp; itemp = x[j*2+1]; x[j*2+1] = x[i*2+1]; x[i*2+1] = itemp; } }}
编译可以通过,运行时Trouble running Target CPU: *** Runtime error at PC = 00000994 Resource(s) L Unit Write Port on side B in conflict in E1 phase. Ref SPRU189F Sec 3.7, Sec 4.5, Sec 7.2
我看过SPRU189F 讲的是汇编程序和通道的东西,看不出关联,求专家给点方向和解答。
penghui zhang:
另外,我把Numlength值改成128 运行出现Trouble running Target CPU: Illegal opcode (c394a031) at pc = 0x00002328 这样的错误。
TI中文支持网
