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

12 bit from ADC to Q15 for a FFT

I have a project on a STM32F103 using the ADC.

I'm trying to make simple VU meter. I made a litle circuit (a resistor divisor and a decoupling capacitor) to put the audio signal into de uC. Becouse of the resistor I get 2048 counts for no audio input.

So, when I put audio to the systems I get my ADC sampling it around 2048. Now I want to convert 16 bits unsigned (but centered at 2048) to Q15 to use CMSIS FFT_Q15

Is there any CMSIS function to do that? Is there a simple way to do that?

Thank!

Parents
  • This is part of my code:

     

    	for(i=0;i<128;i+=2)
    	{
    		FFT_ADCvalues[i]=(q15_t)((int16_t)(DMA_ADCvalues[i/2]-2048)<<3);
    		FFT_ADCvalues[i+1]=(q15_t)0;
    	}
    	arm_cfft_q15(&arm_cfft_sR_q15_len64, FFT_ADCvalues, 0, 1);
    	arm_cmplx_mag_q15(FFT_ADCvalues, MAG_of_fft, 64);

    As I have 12 bits binary offset stored in an unsigned int16_t I'm trying to convert to q15 but it seems that don't work ok, becouse the result of arm_cmplx_mag_q15 is 255,0,0,0,0,0,0,.....

     

    So, what am I doing wrong?

Reply
  • This is part of my code:

     

    	for(i=0;i<128;i+=2)
    	{
    		FFT_ADCvalues[i]=(q15_t)((int16_t)(DMA_ADCvalues[i/2]-2048)<<3);
    		FFT_ADCvalues[i+1]=(q15_t)0;
    	}
    	arm_cfft_q15(&arm_cfft_sR_q15_len64, FFT_ADCvalues, 0, 1);
    	arm_cmplx_mag_q15(FFT_ADCvalues, MAG_of_fft, 64);

    As I have 12 bits binary offset stored in an unsigned int16_t I'm trying to convert to q15 but it seems that don't work ok, becouse the result of arm_cmplx_mag_q15 is 255,0,0,0,0,0,0,.....

     

    So, what am I doing wrong?

Children