2018-07-09 04:57 AM
Hello,
I have a question as to whether stm8L051F3 can do/calculate the floating operation or not,
please help to let me know it,
currently I can't check it with printf function, because if using the library with tool option,
I got the size over error,
example :
float devided_Voltage = 0;
float high_Voltage = 0; devided_Voltage = (float)(rawADValue / ADC_MAX_RESOLUTION * ADC_MAX_INPUT); high_Voltage = (devided_Voltage * (RESISTER_R8 + RESISTER_R9)) / RESISTER_R9;thanks.
#stm8l051f32018-07-09 05:25 AM
I have a question as to whether stm8L051F3 can do/calculate the floating operation or not, ...
What is that ?
Doesn't have ST a STM8 forum anymore ?
From memory, I think no STM8 has a FPU, so you would need to use floating point emulation. That requires an appropriate library, and usually means a few kilobytes more.
2018-07-09 06:39 AM
Most micro-controllers can do floating point in software, even the 8-bit ones from 40 year ago.
If it runs out of space then likely the library exceeds the program space in your device. Use a bigger device, or consider using other methods, like fixed point and scaling.
Perhaps the system supports ftoa()
Or you can scale to an integer and print
float f = 12.345f;
int i = (int)(f * 1000.0f);
printf('%d.%03d\n', i/1000, i%1000); // for positive values
2018-07-09 07:40 AM
Hello, AvaTar,
thankful for rapid reply,
I need more information as to your opinion, please help to let me know it and to use for my project,
1. how can I use floating point emulation with library ? maybe need to know the procedure with detailed example,
Could you please kindly help to provide the information in detail ?
I am using IAR embedded workbench for compile,
thankful for your support in advance,
thanks.
2018-07-09 08:13 AM
I need more information as to your opinion, please help to let me know it and to use for my project, ...
I think I can't help you, I don't work with the STM8, nor do I have an IDE for STM8 devices.
Or do you use another MCU, and mis-spelled it's name ?
For IAR, I would consult the quite extensive program help / documentation.
2018-07-16 02:36 AM
All compilers for the STM8 come with a software floating-point implementation. They all support the C float datatype, but none of them support double or long double (see
http://www.colecovision.eu/stm8/compilers.shtml
).IAR tends to be one of the better compilers when it comes to standard compliance and completeness of the implementation, so you shouldn't run into any problems functionality-wise. When optimizing for speed, IAR also has the fastest floating-point implementation (i.e. achieves higher Whetstone scores than current Cosmic, Raisonance or SDCC, see again
http://www.colecovision.eu/stm8/compilers.shtml
).Philipp