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

Does nrf51822 support asinh, cosh etc.

Does nrf51822 support asinh, cosh, sin, cos, tan ...

  • The chip itself doesn't support anything except the ARM instruction set, which for a Cortex-M0 includes no floating point functions at all. However the compiler will compile floating point code and math functions and link in enough library functions to make them work. Those libraries will use integer arithmetic to perform the floating point calculations.

    Taking a look at one such function, multiplying two doubles together is about 150 instructions, complex functions like sin() are going to take a lot of individual basic operations like that, so it's going to be pretty slow. Even working with floating point in general with an emulation library like this is slow.

    So what do you need it for? There may be better ways to do what you want using integer arithmetic and some lookup tables or similar.

  • Because I need use those functions to get the results.

    the equation:

     - S=6.28*n*sqrt((c*c*l+648943.8)/94.2)-0.1047n*n*c*c
     - t=asinh((sin(a)*f+s*p)/(cos(a)*f))
     - m=asinh(tan(a))
     - h=cos(a)*f/p*(cosh(t)-cosh(m))
    

    n, c, l, a, f, p are variables. s, h are results.

    I do not need fast computing speed, to get one result per second is enough. can nrf51822 achieve the required?

    thanks!

  • For anybody wanting a response, the gcc toolchain has the math lib, all done in software (slow), but working.

    You just need to include it in your makefile by adding a -lm in the LIB variable and of course add #include <math.h> in your files if you use an IDE.

Related