Skip to main content
Visitor II
July 9, 2018
Question

stm8l051f3 can do for floating operation ????

  • July 9, 2018
  • 2 replies
  • 1776 views
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
    This topic has been closed for replies.

    2 replies

    Visitor II
    July 9, 2018
    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.

    Visitor II
    July 9, 2018
    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.

    Visitor II
    July 9, 2018
    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.

    Graduate II
    July 9, 2018
    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