cancel
Showing results for 
Search instead for 
Did you mean: 

stm8l051f3 can do for floating operation ????

edmond yun
Associate II
Posted on July 09, 2018 at 13:57

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.

#stm8l051f3
5 REPLIES 5
AvaTar
Lead
Posted on July 09, 2018 at 14:25

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.

Posted on July 09, 2018 at 15:39

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()

http://www.ars-informatica.ca/eclectic/ftoa-convert-a-floating-point-number-to-a-character-array-on-the-arduino/

 

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 09, 2018 at 14:40

 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.

Posted on July 09, 2018 at 15:13

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.

Posted on July 16, 2018 at 09:36

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