|
请问,参照例程使用Q15进行FFT和IFFT运算,发现FFT输入数据和IFFT输出数据差距较大,请问有大神做过相关功能吗?
static void arm_rfft_q15_app(void)
{
uint16_t i,j;
arm_rfft_instance_q15 S;
fftSize = 1024;
ifftFlag = 0;
doBitReverse = 1;
arm_rfft_init_q15(&S, fftSize, ifftFlag, doBitReverse);
/*store based on real,real,real....*/
for(i=0; i<1024; i++)
{
/* 51.2Hz???,???1024Hz?
arm_sin_q15???????[0, 32768), ???20??????????,
32768 / 20 = 1638.4
*/
j = i % 20;
testInput_q15_50hz[i] = arm_sin_q15(1638*j);
//testInput_q15_50hz[i] = 15 + 10*arm_sin_f32(2*PI*i*100/1024) + 5.5*arm_sin_f32(2*PI*i*150/1024) ;
//printf("%d\r\n", testInput_q15_50hz[i]);
}
/*output stored based on real,image,real,image.....*/
arm_rfft_q15(&S, testInput_q15_50hz, testOutput_q15_50hz);
for(i=0; i<fftSize; i++)
{
printf("%d\r\n", testOutput_q15_50hz[i]);
}
for(i = 0; i < fftSize; i++)
{
testOutput_f32_10khz[i] = (float32_t)testOutput_q15_50hz[i]/32; //?????
}
arm_cmplx_mag_f32(testOutput_f32_10khz, testOutput, fftSize);
for(i=0; i<fftSize; i++)
{
//printf("%f\r\n", testOutput[i]); //delete for tests
}
}
static void arm_rifft_q15_app(void)
{
fftSize = 1024;
ifftFlag = 1;
doBitReverse = 1;
uint8_t i;
arm_rfft_instance_q15 S;
arm_rfft_init_q15(&S, fftSize, ifftFlag, doBitReverse);
arm_rfft_q15(&S, testOutput_q15_50hz, testOutput1_q15_50hz);
printf("printf the ifft data.");
for(i=0; i<fftSize; i++)
{
printf("%d\r\n", testOutput1_q15_50hz[i]);
}
}
int main(void)
{
//uint8_t ucKeyCode;
uint8_t read;
const char buf1[] = "½ÓÊÕµ½´®¿ÚÃüÁî1\r\n";
bsp_Init();
PrintfLogo();
PrintfHelp();
bsp_StartAutoTimer(0, 100);
while (1)
{
/* CPU bsp.c */
bsp_Idle();
if (comGetChar(COM1, &read))
{
switch (read)
{
case '1':
comSendBuf(COM1, (uint8_t *)buf1, strlen(buf1));
arm_rfft_q15_app();
break;
case '2':
arm_rifft_q15_app();
break;
default:
break;
}
}
}
}
|
|