{
COMPLEX temp1,temp2 /*temporary storage variables */
int i,j,k /*loop counter variables */
int upper_leg, lower_leg/*index of upper/lower butterfly leg */
int leg_diff/*difference between upper/lower leg */
int num_stages=0/*number of FFT stages, or iterations */
int index, step /*index and step between twiddle factor*/
/* log(base 2) of # of points = # of stages */
i=1
do
{
num_stages+=1
i = i *2
} while (i!=N)
/* starting difference between upper and lower butterfly legs*/
leg_diff = N/2
/* step between values in twiddle factor array twiddle.h */
step = 512 / N
/* For N-point FFT */
for ( i = 0 i <num_stages i++ )
{
index = 0
for ( j = 0j <leg_diff j++ )
{
for ( upper_leg = jupper_leg <N upper_leg += (2*leg_diff) )
{
lower_leg = upper_leg + leg_diff
temp1.real=(Y[upper_leg]).real + (Y[lower_leg]).real
temp1.imag=(Y[upper_leg]).imag + (Y[lower_leg]).imag
temp2.real=(Y[upper_leg]).real - (Y[lower_leg]).real
temp2.imag=(Y[upper_leg]).imag - (Y[lower_leg]).imag
(Y[lower_leg]).real = ((long)temp2.real * (w[index]).real)/8192
(Y[lower_leg]).real -= ((long)temp2.imag * (w[index]).imag)/8192
(Y[lower_leg]).imag = ((long)temp2.real * (w[index]).imag)/8192
(Y[lower_leg]).imag += ((long)temp2.imag * (w[index]).real)/8192
(Y[upper_leg]).real = temp1.real
(Y[upper_leg]).imag = temp1.imag
}
index+=step
}
leg_diff = leg_diff / 2
step *= 2
}
/* bit reversal for resequencing data */
j=0
for ( i=1 i <(N-1) i++ )
{
k = N / 2
while ( k <= j)
{
j = j - k
k >>= 1
}
j = j + k
if ( i <j )
{
temp1.real = (Y[j]).real
temp1.imag = (Y[j]).imag
(Y[j]).real = (Y[i]).real
(Y[j]).imag = (Y[i]).imag
(Y[i]).real = temp1.real
(Y[i]).imag = temp1.imag
}
}
return
}
参考一下的吧,这个是TI官方的在5416上实现的程序~
用CCS编程软件,这是TI公1司DSP的程序编译环境,和C语言编译环境类似,容易上p手3。但是,你在编程的时候最好能找一y些例程来看,这样学起来比0较快,如果你有C语言编程的基础的话就更好了p。另外,硬件方6面需要编程器和开h发板,需要安装驱动。当然,也j可以6不h用硬件编程,CCS有模拟的功能,它利用计1算机的内3存作为8DSP存储器来实现,但是,这种方8法不s能验证你的程序能否在硬件上m正常工z作,是初学者入e门m的最好方4法。j郡kなwan∮m¢撷u薛écvёkな欢迎分享,转载请注明来源:内存溢出
评论列表(0条)