This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FFT Computation using CMSIS DSP library

I have a code that computes FFT using fftpack functions npy_rffti and npy_rfftf . I want to replace them using arm library functions. I have a real signal. I wrote the below code.

Fullscreen
1
2
3
4
5
6
7
8
9
arm_rfft_fast_instance_f32 rfft_instance;
arm_rfft_fast_init_f32(&rfft_instance, 1024);
static float32_t *rfft_result;
rfft_result = malloc(n * sizeof(float32_t));
arm_rfft_fast_f32(&rfft_instance, accel_copy, rfft_result, 0);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Below is my existing code with fftpack functions:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int len_rffti = 2*n + 15; /* 15 extra 32-bit ints used as storage in fftpack's state */
Treal* rffti = malloc(len_rffti * sizeof(Treal));
npy_rffti(n, rffti); /* calculates rffti */
int len_buf = (n/2 + 1) * 2; /* n+1 if n is odd. otherwise n+2. buf[0] is DC component and is ignored */
Treal* buf = malloc(len_buf * sizeof(Treal));
/* fill raw accel signal into buffer */
buf[0] = 0.0f;
for (i = 0; i < n; i++) {
buf[i+1] = (Treal) accel[i];
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Both produce very different values of FFT. What am i doing wrong? Any help is appreciated. Thanks

0