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 on LPC4088, why?
Hi expert,
I am trying to use arm_cfft_q31 to compute Q31 format FFT, and i first grasp data from arm_fft_bin_data.c and change the input to q31 format. The float version works correctly while the Q31 format works wrong, I am using LPC4088, GCC and libarm_coretexM4l_math.a.
BTW: the CMSIS DSP lib is from https://github.com/ARM-software/CMSIS, is there any thing wrong i use the library, and who else meet the same problem?
- 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); } }