If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

# Compiler/MSP430F5529: MSP dsplib confusion!

Part Number: MSP430F5529

Tool/software: TI C/C++ Compiler

First post on here so go easy on me!

I'm trying to get my head around the fixed point FFT code in MSP dsplib, in particular msp_fft_fixed_q15.

The example code initialises the input array using the msp_sinusoid_q15 utility, which presumably puts q15 results into the input array for the FFT to work on.

The parameter I am passing to the sinusoid for the amplitude is 0.5 as a q15, and the result that is returned from msp_sinusoid has a peak amplitude of about +/-16384 decimal which makes sense.

When I run the FFT, I am having trouble interpreting the scaling of the result.

The MSP dsp lib user guide says that the results for a 256 point FFT can be interpreted as a q8 result +/- 127.00000, or as a int16_t result divided by 128.

If I want to compute the magnitudes of each of the complex results, is it best to use the _QNmag function in the Qmath library, and make N=8 , i.e. _Q8mag()?

If I do that, is the result then in q8 format? I want to get the magnitudes into dB eventually, so I presume I can stay in q8 format to get a dB result using +/- 128 dB, or is that too simplistic?

If I don't use QNmag, how do I get the correctly scaled magnitude from the interger real and imaginary parts?

Do I need to multiply each by 128 then square, add and square root?

I've gone round in circles on this, but I am quite new to the complexities of FP maths!

For the moment I am not too worried about precision and resolution etc.

TIA.

• Having done a bit more digging, I think I understand that for a pure sine input of peak magnitude 1, the FFT result would show a peak at that frequency of magnitude 128 (N/2), which is the output range limit for q8. Rescaling by dividing by 128 gives a result of 1 full scale, which gives 20*log10(1) = 0 dB.
• Andy,

Glad you were able to figure out the answer to your question. Thank you for following up!

**Attention** This is a public forum