DSP TMS320C6657中FFT函数的调用与具体使用方法

该博客详细介绍了如何在TI DSP C6657上使用库函数DSPF_sp_fftSPxSP进行1024点FFT变换,包括库的下载、头文件路径和库文件路径的添加,以及旋转因子和位反位表的生成。同时,提供了实际的测试程序,并将结果与MATLAB进行可视化对比,验证了DSP上的FFT运算准确性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先明确一点,C6678中FFT的函数形式为:
在这里插入图片描述

N : length of FFT in complex samples ptr_x : pointer to complex data
input ptr_w : pointer to complex twiddle factor ptr_y : pointer to
complex output data brev : pointer to bit reverse table containing 64
entries n_min : should be 4 if N can be represented as Power of 4
else, n_min should be 2 offset : index in complex samples of sub-fft
from start of main fft n_max : size of main fft in complex
samples(可令n_max=N)

其中,64位bit反位表brev为: unsigned char brev[64] = { 0x00, 0x20, 0x10, 0x30,
0x08, 0x28, 0x18, 0x38, 0x04, 0x24, 0x14, 0x34, 0x0c, 0x2c, 0x1c,
0x3c, 0x02, 0x22, 0x12, 0x32, 0x0a, 0x2a, 0x1a, 0x3a, 0x06, 0x26,
0x16, 0x36, 0x0e, 0x2e, 0x1e, 0x3e, 0x01, 0x21, 0x11, 0x31, 0x09,
0x29, 0x19, 0x39, 0x05, 0x25, 0x15, 0x35, 0x0d, 0x2d, 0x1d, 0x3d,
0x03, 0x23, 0x13, 0x33, 0x0b, 0x2b, 0x1b, 0x3b, 0x07, 0x27, 0x17,
0x37, 0x0f, 0x2f, 0x1f, 0x3f };

旋转矩阵(旋转因子)ptr_w为: void tw_fft_gen (float *w, int n) { int i, j, k; for
(j = 1, k = 0; j <= n >> 2; j = j << 2) { for (i = 0; i < n >> 2; i +=
j) {
#ifdef _LITTLE_ENDIAN w[k] = (float) sin (2 * PI * i / n); w[k + 1] = (float) cos (2 * PI * i / n); w[k + 2] = (float) sin (4 * PI * i / n);
w[k + 3] = (float) cos (4 * PI * i / n); w[k + 4] = (float) sin (6 *
PI * i / n); w[k + 5] = (float) cos (6 * PI * i / n);
#else w[k] = (float) cos (2 * PI * i / n); w[k + 1] = (float) -sin (2 * PI * i / n); w[k + 2] = (float) cos (4 * PI * i / n); w[k + 3] = (float) -sin (4 * PI * i / n); w[k + 4] = (float) cos (6 * PI * i /
n); w[k + 5] = (float) -sin (6 * PI * i / n);
#endif k += 6; } } }

DSPF_sp_fftSPxSP函数的调用方式为:
1.下载库

将下载好的库“dsplib_c66x_3_1_0_0”复制到CCS的安装路径下

2.添加头文件路径 右键点击工程–>Properties–>Build–>c6000 Compiler–>Include Options 在这里插入图片描述

3.添加库文件和库文件路径 右键点击工程–>Properties–>Build–>C6000 Linker–>File Search Path添加库文件和库文件路径
在这里插入图片描述

完成以上的准备工作后便可进行DSPF_sp_fftSPxSP函数的调用了。

在DSPC6657上的实际测试程序

#include <stdio.h>
#include <stdlib.h>
#include <c6x.h>
#include <math.h>
#include <dsplib.h>

#define FFT_NUM                                1024             //单次FFT变换数据个数
#define Double_FFT_NUM                  FFT_NUM * 2 //单次FFT变换数据个数的两倍
#define PI                                             3.141592654  //圆周率

float sin_data[1024] =
{
   
 1.000, 0.951, 0.809, 0.588, 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, -0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000,
 -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809,
 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309,
 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309,
 -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809,
 1.000, 0.951, 0.809, 0.588, 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000,
 -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, -0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809,
 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhengky6

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值