Skip to main content
RPiep.1
Visitor II
July 10, 2020
Question

How can i implement the math library in the STM32CubeIDE? I use the STM32L011 and i want to implement the atan2(x,y) function. But I can not get a working result....

..

This topic has been closed for replies.

2 replies

KnarfB
Super User
July 10, 2020

No need to implement, it already exists. Add #include <math.h> to your source code and add linker flag -lm That brings in the math lib for gcc.

For the curious: Sources are roughly here: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libm/math/e_atan2.c

Tesla DeLorean
Guru
July 10, 2020

Running floating point on my L011, but not using CubeIDE. ST has a free Keil License for their Cortex-M0(+) devices.

Make sure to enable all options/checkboxes to pull in the appropriate C run-time libraries, including floating point support.

The chips have relatively small Flash, so I'd imagine if you pull in a lot of the transcendental stuff things could get tight.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..