This thread has been locked.

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.

CMSIS DSP Lib q31 functions with RM46L852

Other Parts Discussed in Thread: RM46L852

Hello,

I am getting started with CMSIS DSP lib.

I have recompiled ti_math_Cortex_R4_lspf.lib.lib using Hercules Safety MCU Cortex-R4 CMSIS DSP Library (v1.0.0)  with CCSv5.3 and added to a new project to test arm_sin_cos_example_f32.c on a RM46L852.

It works as attended (use of arm_cos_f32, arm_sin_f32, arm_mult_f32 and arm_add_f32 functions).

I tried to make the same example using q31_t format and lib functions instead of f32.

I have a strange behaviour while using arm_cos_q31 and arm_sin_q31 functions. arm_mult_q31 seems to work.

I have converted const float32_t testInput_f32[MAX_BLOCKSIZE] using angle values in radians to const q31_t testInput_q31[MAX_BLOCKSIZE] using normalized angle [0-1].

I have hereto attached my function, screenshot of calculation result in CCS in Q31 format and excel conversion sheet (Test_arm_sin_cos_example_q31.zip).

I have no explanation to the cos and sin result.

Any idea ?

Test_arm_sin_cos_example_q31.zip
  • I think the angle should be normalized to -1:1 and scale by 2^31. Haven't seen the q lib documentation, what is the range of the input to the q_sin/cos() functions?

  • Hello,

    for q31, Lib documentation, "The input to the floating-point version is in radians while the fixed-point Q15 and Q31 have a scaled input with the range [0 1) mapping to [0 2*pi)."

  • Baptiste,

    Sorry for the delay in my answer.
    I was able to run your test code and it is working fine for me.

    In your original post, you said that you re-compiled the library (arm_math_Cortex_R4_lspf).
    I just want to be sure that you use the correct pre-defined symbol in the project. Here are the symbol you need:

    CCS
    ARM_MATH_MATRIX_CHECK
    ARM_MATH_ROUNDING
    FPU_PRESENT

    To compile the library for a big endian application, the following pre-define name as to be added:

    ARM_MATH_BIG_ENDIAN

    Can you confirm that it is the way you did it?

    Thanks and Regards,