This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F2812:FFT 在 F2812上不工作

Guru**** 2382250 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1301752/tms320f2812-fft-is-not-working-on-f2812

器件型号:TMS320F2812

大家好!

我的系统由 FIR16 LPF、FIR16 HPF 和 RFFT32_512组成。

 在 FFT.calc 函数的末尾没有更新我的 FFT_MAG_OUT。

以下是我的链接器配置

    .othersys_coefffilt              	    					>  EXT_SRAM     		PAGE = 1
    .othersys_firfilter      	 								>  EXT_SRAM  			PAGE = 1
    othersys_x_delay_buffer      		    					>  L01SARAM     		PAGE = 1
    othersys_y_delay_buffer      		    					>  L01SARAM     		PAGE = 1
    othersys_z_delay_buffer     		    				    >  L01SARAM     		PAGE = 1
    .mysys_lpfdb      		ALIGN(0x100)					    > L01SARAM     			PAGE = 1
    .mysys_hpfdb      		ALIGN(0x100)					    > L01SARAM     			PAGE = 1
    .mysys_coeff      		 								    > L01SARAM     			PAGE = 1
    .mysys_fft      											> L01SARAM     			PAGE = 1
    FFTipcb              	ALIGN(0x400)					    > H0SARAM |  L01SARAM 	PAGE = 1
    .mysys_ext												    > EXT_SRAM				PAGE = 1
    FFTtf													    > EXT_SRAM				PAGE = 1

FIR16HPF 的运行频率为2500Hz、其输出将为 FFT 输入。

RAM 内存非常有限、因此必须初始化外部 SRAM 上的 Twiddle Factors。 (是不是问题??)

请查看以下代码、我不确定缺少什么内容。

感谢您的任何帮助。

#define FFT_SIZE            512
#define FFT_CB_SIZE         FFT_SIZE+2
#define __MYSYS_FFTCB__           __attribute__((section("FFTipcb")))
#define __MYSYS_EXT__                     __attribute__((section(".mysys_ext")))
//...
//...
__MYSYS_FFTCB__ int32_t ipcb[FFT_CB_SIZE];
__MYSYS_EXT__ int32_t fft_mag_out[FFT_SIZE]; // No_memory on RAM so it's ext
__MYSYS_FFT__ RFFT32  rfft = RFFT32_512P_DEFAULTS;
const long win[FFT_SIZE/2]=HAMMING512;

typedef struct
{
    RFFT32*      RFFT;
    struct{
        int32_t     RawBuff_Q31[FFT_SIZE]__attribute__((aligned(FFT_SIZE*2)));
        uint16_t    RawIndex;
        int32_t     ReadyToUseBuff_Q31[FFT_SIZE]__attribute__((aligned(FFT_SIZE*2)));
        uint16_t    RTUIndex;
    }Input;

}RFFT_t; 
typedef struct
{
    DualBuffer_t InputBuff;
    LPF_t       LPF;
    HPF_t       HPF;
    RFFT_t      RFFT;
}MySys_t;

__MYSYS_EXT__ MySys_t MY_SYS;

void FFT_Init(RFFT_t * this)
{
    memset(&ipcb[0], 0,  ARRAY_SIZE(ipcb));
    memset(&fft_mag_out[0], 0, ARRAY_SIZE(fft_mag_out));
    this->Input.RTUIndex = 0;
    this->Input.RawIndex = 0;
    memset(this->Input.RawBuff_Q31, 0,  ARRAY_SIZE(this->Input.RawBuff_Q31) );
    memset(this->Input.ReadyToUseBuff_Q31, 0, ARRAY_SIZE(this->Input.ReadyToUseBuff_Q31) );
    this->RFFT = &rfft;
    this->RFFT->ipcbptr = &ipcb[0];
    this->RFFT->magptr = &fft_mag_out[0];
    this->RFFT->winptr  = (long *)&win[0];           // Window coefficient array
    this->RFFT->init(this->RFFT);                     // Twiddle factor pointer initialization
}
void FFT_Compute(RFFT_t * this)
{
    RFFT32* rff = this->RFFT;
    RFFT32_brev(this->Input.ReadyToUseBuff_Q31, &ipcb[0], FFT_SIZE); // Bit reversed
    this->RFFT->calc(rff);
    //this->RFFT->split(rff);                    // Post processing to get the correct spectrum
    //this->RFFT->mag(rff);                      // Q31 format (abs(ipcbsrc)/2^16).^2
}
void MYSYS_Prepare(...)
{
    //....
    MY_SYS->HPF.OutBuff[MY_SYS->HPF.OutIndex++] = hpfOutput;
    int32_t val  = (int32_t)hpfOutput << 15;
    MY_SYS->RFFT.Input.RawBuff_Q31[MY_SYS->RFFT.Input.RawIndex++] = val;
    if (MY_SYS->RFFT.Input.RawIndex == FFT_SIZE)
    {
        memcpy( &MY_SYS->RFFT.Input.ReadyToUseBuff_Q31[0], &MY_SYS->RFFT.Input.RawBuff_Q31[0], FFT_SIZE);
        EventNofication(); // Trigger the computation
        MY_SYS->RFFT.Input.RawIndex = 0;
    }
    //...
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您是否运行了相应的 C2000示例?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我启用了下面的代码、它就可以正常工作了。

    //this->RFFT->SPLIT (RFF);//进行后处理以获得正确的频谱
    //this->RFFT->MAG(RFF);// Q31格式(abs(ipcbsrc)/2^16)。^2

    这->RFFT->calc(RFF)未填充幅度缓冲区。