2019-10-29 05:56 PM
2019-10-29 07:24 PM
https://www.quinapalus.com/efunc.html
2019-10-29 09:06 PM
how can you do it on smt32CubeIde? i tried it, that functions works with numbers ex: log(8) or log10f(1000) but when you have variable x= 100 and you do log(x) or logf(x) the compiler give an error
2019-10-29 11:19 PM
This is not a STM32 specific question, but a C language basics.
2019-10-29 11:27 PM
Sorry, but the phrase " ...do it on smt32CubeIde?" suggests there is something more basic missing.
2019-10-29 11:29 PM
> when you have variable x= 100 and you do log(x) or logf(x) the compiler give an error
Which compiler? What error? Show us a minimal example exhibiting the problem - a screenshot, perhaps.
JW
PS. And please change your user name to a normal nick.
2019-10-29 11:57 PM
2019-10-30 12:09 AM
Yes, it's library linking and it is C basics...
Newlib-nano library doesn't include some not so often used code by default.
https://stackoverflow.com/questions/5419366/why-do-i-have-to-explicitly-link-with-libm
2019-10-30 12:15 AM
And what exactly is not clear from that error message? Check if your linker script (*.ld file) has the correct FLASH size corresponding to the real MCU part. If it has, then... reduce the code size or/and change the MCU to one with a bigger flash. This is a clear example of the fact that HAL library and CubeMX generated code is not only full of bugs, but also a bloatware...
P.C. Useful tool to analyze code and data sizes: http://www.sikorskiy.net/prj/amap/
2019-10-30 01:39 AM
If the compiler doesn't provide math.lib or if the code size is important, use interpolation, create a look up table of precalculated points and linearly interpolate between them. It's usually what is done in 8 bit MCU when speed and codesize is optimized in exchange or a lower accuracy. Sometime the variables are integer (value_x1000) to go a notch further. Check on Q31 pseudo fixed point type.