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

Fixed point rfft issue in CMSIS-DSP

Hi all,

I tried the rfft for q31 fixed point. The scale of the output is different than what I thought.

I use 32 pt rfft. Input is constant 2^10=1024 (in Q31). The DC term output should be 2^10 * 2^5 / 2^4 = 2048 (in Q5.27), where multiplication of 2^5 is due to 32 pt fft, and division of 2^4 is due to input scale in each stage as mentioned below. All the terms other than DC one should be zeros.

However, my result for DC term is 1024 + j 0 (I expect 2048+j 0).

Anyone has any idea?

Paul

Code and results are attached.

Code:

void test_fft()
{
    arm_rfft_instance_q31 fft_st;
    arm_status status;
    int i;
    int32_t   len_fft=32;
    uint32_t  ifftFlagR=0;
    uint32_t  bitReverseFlag=1 ;
    static int32_t xfft[32];
    static int32_t yfft[64];
    for (i = 0; i < len_fft; i++)
    {
      xfft[i] = (int32_t) 1024;
    }
    for (i = 0; i < len_fft; i++)
    {
      am_util_stdio_printf("%d: %d\n", i, xfft[i]);
    }
    am_util_stdio_printf("\n");
    arm_rfft_init_q31(&fft_st, len_fft, ifftFlagR, bitReverseFlag);
    arm_rfft_q31(&fft_st, xfft, yfft);
    for (i = 0; i < ((len_fft>>1) + 1); i++)
    {
      am_util_stdio_printf("%d: %d + j %d  \n", i, yfft[2*i], yfft[2*i+1]);
    }
    am_util_stdio_printf("\n");
   
}
Results:
Input:
0: 1024
1: 1024
2: 1024
3: 1024
4: 1024
5: 1024
6: 1024
7: 1024
8: 1024
9: 1024
10: 1024
11: 1024
12: 1024
13: 1024
14: 1024
15: 1024
16: 1024
17: 1024
18: 1024
19: 1024
20: 1024
21: 1024
22: 1024
23: 1024
24: 1024
25: 1024
26: 1024
27: 1024
28: 1024
29: 1024
30: 1024
31: 1024
Output:
0: 1024 + j 0
1: 0 + j 0
2: 0 + j 0
3: 0 + j 0
4: 0 + j 0
5: 0 + j 0
6: 0 + j 0
7: 0 + j 0
8: 0 + j 0
9: 0 + j 0
10: 0 + j 0
11: 0 + j 0
12: 0 + j 0
13: 0 + j 0
14: 0 + j 0
15: 0 + j 0