2020-04-29 08:07 PM
I was trying to use arm_rfft_q15 .In the CMSIS documentation for arm_rfft_q15, it says the output format is Q7.9 and 6 bits should be upscaled when the input RFFT size is 128 .
Why does the amplitude have halved by using arm_rfft_q15 ?
uint16_t i;
float32_t testout[128],testoutf[128],amplitude;
arm_rfft_instance_q15 SS;
static q15_t testInput_q15[128];
static q15_t testOutput[256];
arm_rfft_init_q15(&SS,128,0,1);
for(i=0;i<128;i++)
{
testInput_q15[i]= arm_sin_q15(256*i);
}
arm_rfft_q15(&SS, testInput_q15, testOutput);
for(i=0;i<128;i++)
{
testoutf[i]= (float32_t)testOutput[i]/512;
}
arm_cmplx_mag_f32(testoutf,testout,64);
amplitude=testout[1]/64;
2020-04-30 04:01 AM
Read up on the meaning of the q data type & fixed point dsp. Scaling inputs and outputs is common and is used to get maximum resolution while preventing overflows.
Also, what do 512 and 64 mean in your code? You need to be careful about data types and constants to prevent the compiler from doing things you might not expect. Hint: 512 is not the same number as 512.0f.