0

STM32F407 でいくつかの FFT 計算を行っており、CMSIS DSP ライブラリで使用できるさまざまな FFT 関数を比較したいと考えています。f32 CFFT 関数を使用しているときは期待どおりに動作しますが、q31/q15 関数を使用しようとすると、それぞれの cfft 関数を呼び出すときに「arm_cfft_sR_q31_len4096」または arm_cfft_sR_q15_len4096 が宣言されていないというエラーが表示されます。arm_const_structs.h を定義すべき場所に含めましたが、どうやらそうではありませんか? f32 バージョンの関数では arm_cfft_sR_f32_len4096 で動作しますが、何が問題なのですか?

私の fft 計算の f32 バージョンは次のようになります。

#include "arm_const_structs.h"

float32_t fft_data[FFT_SIZE * 2];

uint16_t util_calculate_fft_value(uint16_t *buffer, uint32_t len, uint32_t fft_freq, uint32_t fft_freq2) 
{
  uint16_t i;
  float32_t maxValue;         // Max FFT value is stored here
  uint32_t maxIndex;          // Index in Output array where max value is

  tmStartMeasurement(&time);  // Record clock cycles

  // Ensure in buffer is not longer than FFT buffer
  if (len > FFT_SIZE)
    len = FFT_SIZE;

  // Convert buffer uint16 to fft input float32
  for (i = 0; i < len ; i++) 
  {
    fft_data[i*2] = (float32_t)buffer[i] / 2048.0 - 1.0; // Real part
    fft_data[i*2 + 1] = 0; // Imaginary part      
  }

  // Process the data through the CFFT module intFlag = 0, doBitReverse = 1
  arm_cfft_f32(&arm_cfft_sR_f32_len4096, fft_data, 0, 1);
  // Process the data through the Complex Magniture Module for calculating the magnitude at each bin
  arm_cmplx_mag_f32(fft_data, fft_data, FFT_SIZE / 2);
  // Find maxValue as max in fft_data
  arm_max_f32(fft_data, FFT_SIZE, &maxValue, &maxIndex);

  if (fft_freq == 0) 
  { // Find maxValue as max in fft data
    arm_max_f32(fft_data, FFT_SIZE, &maxValue, &maxIndex);
  } 
  else 
  { // Grab maxValue from fft data at freq position
    arm_max_f32(&fft_data[fft_freq * FFT_SIZE / ADC_SAMP_SPEED - 1], 3, &maxValue, &maxIndex);

    if (fft_freq2 != 0) 
    {
      // Grab maxValue from fft data at freq2 position
      float32_t maxValue2;                // Max FFT value is stored here
      uint32_t maxIndex2;                // Index in Output array where max value is
      arm_max_f32(&fft_data[fft_freq * FFT_SIZE / ADC_SAMP_SPEED - 1], 3, &maxValue2, &maxIndex2);
      maxValue = (maxValue + maxValue2) / 2.0;
    }
  }

  tmStopMeasurement(&time); // Get number of clock cycles

  // Convert output back to uint16 for plotting
  for (i = 0; i < len / 2; i++) 
  {
    buffer[i] = (uint16_t)(fft_data[i] * 10.0);
  }
  // Zero the rest of the buffer
  for (i = len / 2; i < len; i++) 
  {
    buffer[i] = 0;
  }

  LOG_INFO("FFT number of cycles: %i\n", time.worst);

  return ((uint16_t)(maxValue * 10.0));
}
4

1 に答える 1