It's a bug.

Take a peek at the innards of dsp_vector_rms()

Code: Select all

```
int32_t dsp_vector_rms
(
const int32_t* input_vector_X,
int32_t vector_length,
const int32_t q_format
) {
int32_t vectort_pwr = dsp_vector_power ( input_vector_X, vector_length, q_format );
int32_t mean_square = dsp_math_divide ( vectort_pwr, (vector_length << q_format), q_format );
int32_t rt_mean_sqr = dsp_math_sqrt( mean_square);
return rt_mean_sqr;
}
```

dsp_math_sqrt() does not care which Q format you've specified - it's fixed at Q24 format. The documentation for dsp_vector_rms mentions it using dsp_math_sqrt but doesn't explain this limitation. It refers to a "final value" but this appears to relate to the value of mean_square above. Because of this problem the result of the function is left-shifted by 6 bits in your case - i.e. half the difference between Q24 and your format.

If you try your example using Q24 format and initialise your input vector elements to, say Q24(0.1) you'll get the right answer.