gpt4 book ai didi

c - 在 TMS320C6713 DSK 中运行代码时出错?

转载 作者:行者123 更新时间:2023-11-30 16:55:31 26 4
gpt4 key购买 nike

我正在尝试运行以下代码来在上述型号的DSP处理器中实现FFT。代码是用C语言编写的

//All codes submitted by  Srivatsa Sinha
/*Include Library Files*/
#include <stdio.h>
#include<math.h>

/*Templates*/
//#define ll long long
#define cmp struct complex
#define print_cmp(z) printf("%lf + %lfj\n",z.re,z.im)
#define M_PI 3.14159265358979

struct complex
{
float re;
float im;
}res,w,w_var,t,u;

cmp signal[4];
cmp result[4];
int j,s,k,n,z,x,no_of_bit,rev,pow2[10],m,a;
void calc()
{
pow2[0]=1;
for(k=1; k<10; k++) { pow2[k] = pow2[k-1]*2;}
}

cmp add(cmp a, cmp b)
{
res.re = a.re + b.re;
res.im = a.im + b.im;
return res;
}

cmp sub(cmp a, cmp b)
{
res.re = a.re - b.re;
res.im = a.im - b.im;
return res;
}

cmp mul(cmp a, cmp b)
{
res.re = a.re*b.re - a.im*b.im;
res.im = a.re*b.im + a.im*b.re;
return res;
}

cmp cmp_pow(cmp base, int exp)
{
res.re = 1.0; res.im = 0.0;
for(a=1; a<=exp; a++)
res = mul(res,base);
return res;
}

void bit_rev()
{
no_of_bit = log2(n);
for(z=0; z<n; z++)
{
rev = 0;
for(x=0; x<no_of_bit; x++)
{
if((z>>x)&1)
{
rev = rev|(1<<(no_of_bit-1-x));
}
}
result[rev] = signal[z];
}
}

void fft()
{
bit_rev();
for(s=1; s<=(int)log2(n); s++)
{
m = pow2[s];
w.re = (float)cos(((float)2.0*(float)M_PI)/(float)m); w.im = (float)-1.0*sin(((float)2.0*(float)M_PI)/(float)m);
for(k=0; k<n; k+=m)
{
w_var.re = 1; w_var.im = 0;
for(j=0; j<=(m/2 - 1); j++)
{
t = mul(w_var, result[k+j+(int)(m/2)]);
u = result[k+j];
result[k+j] = add(u,t);
result[k+j+(int)(m/2)] = sub(u,t);
w_var = mul(w_var, w);
}
}

}
}

void dft()
{
w.re = (float)cos(((float)2.0*(float)M_PI)/(float)n); w.im = (float)-1.0*sin(((float)2.0*(float)M_PI)/(float)n);
for(k=0; k<n; k++)
{
result[k].re = 0.0; result[k].im = 0.0;
for(j=0; j<n; j++)
{
result[k] = add(result[k],mul(signal[j],cmp_pow(w,k*j)));
}
}
}

int main()
{
calc();
printf("Enter length of the signal: ");
scanf("%d",&n);
printf("Enter the signal sequence: \n");
for(k=0;k<n; k++)
{
scanf("%f",&signal[k].re);
scanf("%f",&signal[k].im);
}
fft();
printf("The Result of FFT is: \n");
for(k=0; k<n; k++)
{
print_cmp(result[k]);
}
dft();
printf("The Result of DFT is: \n");
for(k=0; k<n; k++)
{
print_cmp(result[k]);
}
return 0;
}

编译前添加以下文件:

hello.cmd The Linker file
rts6700.lib The Library file

虽然代码编译成功,但是构建时出现以下错误:

can't allocate .stack size 00000400 (page 0) in IRAM (avail: 000003ec)
can't allocate .sysmem size 00000400 (page 0) in IRAM (avail: 000003ec)
can't allocate .cio size 00000120 (page 0) in IRAM (avail: 0000010a)
errors in input - ./Debug/FFTa.out not built

请帮忙?

最佳答案

谢谢你给我的记忆。我使用 TI 工具已经有几年了。我无法再访问他们的文档,但看起来您需要设置链接器控制文件。如果您使用 CodeComposer,则需要创建一个目标(或指定一个模拟模型)来定义 RAM 位置。如果您需要从处理器中获得高性能,您将需要深入研究各种内存类型,以最大限度地减少总线延迟。

关于c - 在 TMS320C6713 DSK 中运行代码时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40283759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com