lojos
Newbie
Hello, I am using Arm-Cortex M3 Microcontroller and CMSIS for FFT, my microcontroller does not support floating point unit therefore I have to use fixed point (Q15 or Q31) for calculation.
Before calculate FFT, I need to apply hanning window on to my data collected from ADC 12-bit (0-4095). My ADC data ranges from 1800 ~ 3200.
Here is a sample code I have tried so far. Did I correctly apply?
Before calculate FFT, I need to apply hanning window on to my data collected from ADC 12-bit (0-4095). My ADC data ranges from 1800 ~ 3200.
Here is a sample code I have tried so far. Did I correctly apply?
C:
double hann[512];
uint32_t ADC[512]; /* data range 1800 ~ 3200 */
q31_t input[512]; /* fixed point */
// Hann window
for (int i = 0; i < 512; i++)
{
hann[i] = 0.5 * (1 - cos(2*PI*i/511));
}
// apply hann window to ADC data
for (int j = 0; j < 512; j++)
{
ADC[j] = (ADC[j] - DC) * hann[j];
input[j] = (q31_t)ADC[j] << 19; // convert to fixed point Q31 from 12-bit
}