cancel
Showing results for 
Search instead for 
Did you mean: 

FFT in STM32F7 MCU

Edwin kaus
Associate II
Posted on February 21, 2018 at 13:26

Hello.,

I need to write test code for Audio codec which is interfaced through SAI interface . For this I am generating 1KHz sine wave using DAC and given to codec input and capturing the same through SAI interface . Now how to conclude that signal frequency is 1Khz by using SAI captured samples.

I was suggested to do FFT on those samples ,

>> Is it possible to do FFT on captured sample from SAI interface.

>> To do this Is there any inbuilt algorithm available in CMSIS library. If so which one to use and how to use can anyone suggest me .

#sai #stm32f7
20 REPLIES 20
Posted on February 21, 2018 at 14:13

It's just 'data' why wouldn't you be able to process it any way you choose?

CMSIS provides a DSP Library, perhaps review that

STM32Cube_FW_F7_V1.8.0\Drivers\CMSIS\DSP_Lib\Examples\arm_fft_bin_example

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist
AvaTar
Lead
Posted on February 22, 2018 at 10:50

I'm not sure how a FFT on the target is supposed to do good in this case, i.e. serves the test of the audio codec.

henry.dick
Senior II
Posted on February 22, 2018 at 14:48

Yes. And there are others as well.

You have a few options. Cmsis dsp is one. It has more functionality thanjust fft.

St itself has an appnote on fft as well. Highly specialized. And very fast.

Or you can roll your own. Fft is fairly easy to do.

Posted on February 22, 2018 at 14:38

Sounds like the OP intends to do an FFT of the codec output, to see the output spectrum is 'pure' ... ?

AvaTar
Lead
Posted on February 22, 2018 at 16:13

But why on the target ?

I would have exported sampled analog data to a PC, and done the spectral analysis there.

Last time I checked, the CMSIS_DSP was limited to 2048 point - if I remember correctly.

Posted on February 22, 2018 at 17:06

I'm sure you would. But that doesn't mean everyone else should for everyone of their applications.

Different people have different needs in different applications, you know.

Posted on February 22, 2018 at 18:18

It might have to do with a different understanding of what 'testing' in this context means.

Having additional (and rather complex and complicated) code running on the DUT as part of a verification does not tend to make things easier.

AVI-crak
Senior
Posted on February 22, 2018 at 19:47

Just measure the frequency?

Apply the digital analog of the window filter. The window filter has a phase delay, this is exactly what you need. You need two filters. The first will cut off high-frequency oscillations, the second will be used to control the direction of the phase. To do this, you need to take the data from the first filter and compare it with the output of the second filter.

With apparent simplicity, your measurements can not occur in real time. Therefore, the time stamp at the time of the phase change must be taken from the report number and the system time. Having a real phase transition time - you can calculate the frequency. For reliability, you can accumulate many reports, then the result will have increased accuracy.

Phase transition control takes precedence over the threshold detector - switching always occurs at the top of the wave. And so is the advantage over FFT - you need much less computing and memory.

The window filter works very simply. This is the sum of the reports divided by their number. You do not need to apply a filter to every cycle of the ADC; it's simpler: a new report is added to the sum and the old one is subtracted, the amount is divided by the number of reports, and the cycle repeats.