cancel
Showing results for 
Search instead for 
Did you mean: 

How to use FFT on STM32F427 ?

SAIDHI REDDY SAREDDY
Associate II
Posted on April 12, 2017 at 18:23

How can I use FFT on STM32F427 development board?

Where Can I find arm_math.h file?

Can I use void cr4_fft_1024_stm32(void *pssOUT, void *pssIN, UINT16 Nbin) this FFT function with my board?

#fft-stm32f4 #stm32f427
3 REPLIES 3
Posted on April 12, 2017 at 18:35

The arm_math.h should be in the CMSIS include directory for your tool chain.

It is also present in the DSP library containing the CMSIS DSP functions

STM32F4xx_DSP_StdPeriph_Lib_V1.8.0\Libraries\CMSIS\Include\arm_math.h

It's a function designed for a Cortex-M3, but yes it will run on a Cortex-M4

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 20, 2017 at 15:47

 ,

 ,

Dear Clive,

Thanks for your reply,

I have done fft computation but I got strange results.Please let me know if i did any mistake.

why I am getting the following strange results?

// ADC

 ,

♯ define ADC_RAW_LENGTH 512

// FFT

 ,

// ♯ define FFT_SAMPLES 2048

 ,

♯ define FFT_SIZE ADC_RAW_LENGTH/2

UINT16 ui16ADCRaw[ADC_RAW_LENGTH],ui16ADCCnt = 0,ui16Flag = 0, ui16CalibrateMaxValue = 0,

 ,

FLOAT32 fl32ADCRaw[ADC_RAW_LENGTH], fl32FFTOut[FFT_SIZE], fl32FFTMaxValue = 0,

 ,

UINT32 ui32FFTMaxIndex = 0,

arm_cfft_radix4_instance_f32 FFT_InitStruc,

 ,

arm_cfft_instance_f32 FFT_InitStruc_dsp,

 ,

arm_status status = ARM_MATH_ARGUMENT_ERROR, // default failure

//input data collection with timer interrupt from adc

 ,

void TIM2_IRQHandler(void)

 ,

{

 ,

UINT16 ui16ADC_Value = 0 ,

 ,

TIM_ClearITPendingBit(TIM2, TIM_IT_Update),

ui16ADC_Value = ADC_GetConversionValue(ADC1) ,

 ,

if((ui16ADCCnt <, ADC_RAW_LENGTH) &,&, (ui16ADC_Value >, 500) )

 ,

{

 ,

if((ui16CalibrateMaxValue <, ui16ADC_Value) ) {

 ,

ui16CalibrateMaxValue = ui16ADC_Value,

 ,

}

 ,

fl32ADCRaw[ui16ADCCnt] = (FLOAT32)ui16ADC_Value,

 ,

ui16ADCCnt++,

 ,

fl32ADCRaw[ui16ADCCnt] = 0.0,

 ,

ui16ADCCnt++,

 ,

}

 ,

}

 ,

// FFT calculation

 ,

status = arm_cfft_radix4_init_f32(&,FFT_InitStruc,FFT_SIZE,0,1),

arm_cfft_radix4_f32(&,FFT_InitStruc, fl32ADCRaw),

arm_cmplx_mag_f32(fl32ADCRaw,fl32FFTOut,FFT_SIZE),

arm_max_f32(fl32FFTOut, FFT_SIZE, &,fl32FFTMaxValue, &,ui32FFTMaxIndex),

 ,

// input sample data fl32ADCRaw

 ,

503

 ,

0

 ,

507

 ,

0

 ,

516

 ,

0

 ,

514

 ,

0

 ,

524

 ,

0

 ,

530

 ,

0

 ,

532

 ,

0

 ,

537

 ,

0

 ,

....

//arm_cfft_radix4_f32 function fl32ADCRaw

 ,

388595

 ,

0

 ,

0

 ,

0

 ,

-1186

 ,

1163

 ,

-1087

 ,

0

 ,

4.66130239e+011

 ,

-4.66130239e+011

 ,

-1186

 ,

-1163

 ,

4.66130239e+011

 ,

4.66130239e+011

 ,

-4.66130239e+011

 ,

4.66130239e+011

 ,

0

 ,

0

 ,

-4.66130239e+011

 ,

-4.66130239e+011

 ,

0

 ,

0

 ,

0

 ,

0

 ,

nan (0x7fffff)

 ,

nan (0x7fffff)

 ,

0

 ,

0

 ,

nan (0x7fffff)

 ,

nan (0x7fffff)

 ,

nan (0x7fffff)

 ,

nan (0x7fffff)

 ,

2.48002616e+012

//arm_cmplx_mag_f32 function fl32FFTOut data

 ,

5.66332883e+011

 ,

5.68833212e+011

 ,

1.86279645e+018

 ,

7.30765853e+011

 ,

1.86279645e+018

 ,

1.86279645e+018

 ,

0

 ,

1.86279645e+018

 ,

0

 ,

0

 ,

0

 ,

0

 ,

0

 ,

0

 ,

0

 ,

1.16413673e+013

 ,

0

 ,

1.67605685e+012

 ,

6.25887412e+011

 ,

inf

 ,

1.60195215e+012

 ,

inf

 ,

inf

 ,

0

 ,

inf

 ,

0

 ,

0

 ,

0

 ,

0

 ,

0

 ,

0

 ,

inf

 ,

0

 ,

inf

 ,

inf

 ,

inf

 ,

inf

 ,

inf

 ,

inf

 ,

0

 ,

inf

 ,

0
Posted on April 20, 2017 at 17:32

May be you can find a test suite with examples to test? Or generate some sine wave data to process in a test.

Your ADC acquisition looks a bit odd, I'd recommend using the TIM to trigger the conversion, and pick the data up in the ADC EOC interrupt if you are going to do the processing like this. More generally, you should perhaps use DMA to pull in enough samples so you can process a block at HT/TC interrupts.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..