2017-05-22 03:26 AM
Hello,
I would like to use half precision floating variable in my project but i don't know how. I'm working on a NUCLEO-L073 board that embeds a cortex m0 STM32l073 MCU that does not have any FPU. I'm using the SW4STM32 eclipse environment. I saw that gcc proposes some options :
https://gcc.gnu.org/onlinedocs/gcc-4.5.1/gcc/Half_002dPrecision.html
but i don't know how to set flag or use their specific libraires to activate this feature.
I you have any idea, p
lease feel free to share your thoughts about my issue.
Thank you very much.
Best regards,
Aurélien
2017-05-22 03:36 AM
The gcc link you've given above says among other things:
The
__fp16
type is a storage format only. For purposes of arithmetic and other operations,
__fp16
values in C or C++ expressions are automatically promoted to
float
.
Are you sure you want to use this? Tell us more about your project requirements, if you want to discuss this further.
JW
2017-05-22 03:55 AM
You can surely use float if you want or need it.
I expect the IDE to automatically select the proper emulation library and build options ('soft').
As Jan mentioned, this will have a significant impact on run-time and code size.
2017-05-24 05:22 AM
hi,
Thx for your replies. Actually, i intend to transmit data over the air (sigfox/lora ...) but i'm limited in size and in order to save bytes, i wanted to use half precision float format if possible.
Aurélien
2017-05-24 07:30 AM
Yes, i think you right, i will use scaled integer instead of float, it will be easier and more suitable for my chip and my project.
Thank you very much,
BR,
Aurélien
2017-05-24 07:31 AM
There seems to be no convincing arguments to use float. Using even one variable or constant will pull in a bunch of supportive conversion and calculation routines, hogging up several kBytes.
If it's just for data transfer, integer data types, scaled math and ad-hoc conversion routines can do with much less space.
2017-05-24 09:16 AM
If you understand the range of the numbers being used, then scaling into a suitably sized integer is how this gets done.
Even where something might fit in a 32-bit float, using an integer can give more precision if the range is known/constrained.
Using 16, or 32-bit floating point is a trap for the unwary, and they usually fall into it
2024-02-23 05:52 AM
Hi
I am also got stuck in same situation. I wanted to implement 16bit half precision datatype for stm32 MCU. I am searching the procedure for it on web but none found convincing. I do got information that Clang compiler can be used, but don't know how it can be done for STM32cube ide.
Did you get your job done?
let us know if you have any help me.
Thanks
2024-02-23 06:01 AM
Hi,
you can set it in IDE : menu -> project -> properties ...
set software ... - to use floating lib here.
2024-02-23 06:16 AM
> I wanted to implement 16bit half precision
Why?
JW