This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to include math CMSIS DSP library in NRF9160?

Hello!

1-st question - how can i set preprocessor defines using SES and NRF connect options?
When i set define like: ARM_MATH_CM3 in proj.conf file, i get an error "malformed line".

2-nd question: Ok, i set ARM_MATH_CM3 define in arm_math.h file. Include lines with sources in CMakeLuists.txt

include_directories(src/Include)
target_sources(app PRIVATE src/Source/TransformFunctions/arm_cfft_f32.c)
target_sources(app PRIVATE src/Source/TransformFunctions/arm_cfft_radix8_f32.c)
target_sources(app PRIVATE src/Source/CommonTables/arm_common_tables.c)
target_sources(app PRIVATE src/Source/CommonTables/arm_const_structs.c)


But i get an errors after rebuiling the project like 

#ifndef __IM                                    /*!< Fallback for older CMSIS versions                                         */
  #define __IM   __I
#endif
#ifndef __OM                                    /*!< Fallback for older CMSIS versions                                         */
  #define __OM   __O
#endif
#ifndef __IOM                                   /*!< Fallback for older CMSIS versions                                         */
  #define __IOM  __IO
#endif


"Unknown type name _I" etc

There is something wrong with my steps of including DSP lib.
How should i correctly include and use math functions in NRF9160?



Best regards.

  • Hi,

    1-st question - how can i set preprocessor defines using SES and NRF connect options?

    You can set it in the CMakeLists.txt with add_definitions()

    ARM_MATH_CM3 define in arm_math.h file. Include lines with sources in CMakeLuists.txt

    The nRF9160 uses a ARM Cortex-M33 CPU. The CMSIS DSP Library is only for Cortex-M7/Cortex-M4/Cortex-M3/Cortex-M0.

    How should i correctly include and use math functions in NRF9160?

    In order to use math.h , set CONFIG_NEWLIB_LIBC=y in your prj.conf


    EDIT 26.05.2020:

    Starting from nRF Connect SDK v1.3.0, there is support for CMSIS Version v5. A arm_math.h library with support for ARM Cortex-M33 / Armv8-M is included there.

    Set these config's in you project to use it:

    CONFIG_CMSIS_DSP=y
    CONFIG_NEWLIB_LIBC=y
    CONFIG_FPU=y
    //Set CONFIG_NEWLIB_LIBC_FLOAT_PRINTF if  printf should be able to print float
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    

    And use

    #include <arm_math.h>
    in the application code to start using CMSIS DSP functions.
Related