请教:我这样计算出来的值是不是对的?为什么每个频率上都有值啊?
程序是这样子:
用ADC采集值填入fft输入buff
void ADC_proc(void)
{
uint16_t ai,cnt;
if(adc_conv_done)
{
adc_conv_done = 0;
for(ai=0;ai<NPT;ai++)
{
lbufin[ai*2] = (float)(adc_buf[ai*2]-2048);
lbufin[ai*2+1] = (float)0;
}
FFT_proc();
HAL_ADC_Start_DMA(&hadc,(uint32_t*)adc_buf,sizeof(adc_buf)/2);
}
}
FFT处理
float lbufin[NPT*2]; /* Complex input vector */
float lbufout[NPT]; /* Complex output vector */
float lbufmag; /* Magnitude vector */
uint16_t fftSize = 64;
uint8_t ifftFlag = 0;
uint8_t doBitReverse = 1;
uint16_t audio_mag;
extern uint8_t audio_intf_flag;
//uint32_t refIndex = 213,
uint32_t testIndex = 0;
__IO uint8_t new_mag_flag;
void FFT_proc()
{
arm_cfft_f32(&arm_cfft_sR_f32_len64, lbufin, ifftFlag, doBitReverse);
arm_cmplx_mag_f32(lbufin,lbufout,fftSize);
arm_max_f32(lbufout, NPT, &lbufmag, &testIndex);
} |
|