Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 6 months ago.
arm_cfft_q31 compute wrong value on LPC4088, why?
Hi Arm Expert,
I am trying to use FFT Q31 format on LPC4088 with library libarm_coretexM4l_math.a under GCC environment. First i grasp the data from arm_fft_bin_data.c, and use arm_cfft_f32 to compute the float version, the value and test case work correctly. But if i change the input data to Q31 format and try to use arm_cfft_q31 do the same thing, seems the output is quite different from the float version(please note the output of testInput_f32_10khz and testInput_int_10khz). Does someone meet this problem?
BTW: I am using the CMSIS DSP from https://github.com/ARM-software/CMSIS . Is there any thing wrong i use the DSP lib?
The following is my testcase codes:
- define TEST_LENGTH_SAMPLES 2048
extern float32_t testInput_f32_10khz[TEST_LENGTH_SAMPLES]; static float32_t testOutput[TEST_LENGTH_SAMPLES/2];
int32_t testInput_int_10khz[TEST_LENGTH_SAMPLES]; static int32_t testOutput1[TEST_LENGTH_SAMPLES/2];
uint32_t fftSize = 1024; uint32_t ifftFlag = 0; uint32_t doBitReverse = 1;
uint32_t refIndex = 213, testIndex = 0, testIndex1 = 0;
int main() { arm_status status; float32_t maxValue; int32_t maxValue1; int k;
for (k = 0; k < TEST_LENGTH_SAMPLES; k++) testInput_int_10khz[k] = (int)testInput_f32_10khz[k];
status = ARM_MATH_SUCCESS;
arm_cfft_f32(&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse); arm_cfft_q31(&arm_cfft_sR_q31_len1024, testInput_int_10khz, ifftFlag, doBitReverse);
printf("testInput_f32_10khz:\n"); for (k = 0; k < TEST_LENGTH_SAMPLES; k++) printf("%d ", (int)testInput_f32_10khz[k]);
printf("\ntestInput_int_10khz:\n"); for (k = 0; k < TEST_LENGTH_SAMPLES; k++) printf("%d ", testInput_int_10khz[k]);
arm_cmplx_mag_f32(testInput_f32_10khz, testOutput, fftSize); arm_cmplx_mag_q31(testInput_int_10khz, testOutput1, fftSize);
arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); arm_max_q31(testOutput1, fftSize, &maxValue1, &testIndex1);
if(testIndex != refIndex || testIndex1 != refIndex) { status = ARM_MATH_TEST_FAILURE; }
printf("maxValue %f maxValue1 %d refIndex %d testIndex %d testIndex1 %d\n", maxValue, maxValue1, refIndex, testIndex, testIndex1);
if( status != ARM_MATH_SUCCESS) { printf("test: failed!\n"); while(1); }
printf("test: pass!\n");
while (true) { led1 = !led1; Thread::wait(500); } }