2021-06-21 12:38 PM
Do the STM32 MCUs that have a floating point unit use it automatically or does it only use it once you have enabled it in the FREERTOS configuration?
Say on a STM32H743 which has a double precision FPU, if I have a floating point calculation in my code will it automatically use the FPU to do the calculation.
The reason I'm asking this is because I am currently looking at freertos and it has an option called ENABLE_FPU, does this mean that I have to enable this to use the FPU at all even if I dont use freertos or does it just let freertos use the FPU and if so, if I am using freertos should I enable it.
Many thanks,
Conor Stewart
2021-06-21 02:30 PM
It needs to be enabled at compile-time in order for the compiler to generate FPU instructions, rather than emulating them in software. This is done in the IDE:
It also needs to be enabled in hardware when your program is starting up. In HAL, this is done with the __FPU_PRESENT and __FPU_USED flags.
Enabling the FPU is the default as far as I can tell.
2021-06-21 03:00 PM
The FPU is a coprocessor, it must be explicitly enabled in code, typically in Reset_Handler or SystemInit(), otherwise the execution of FPU instructions, including push/pop at function prologue/epilogue code (ie float code in main() ), will cause a Hard Fault
You probably don't need to tell FreeRTOS you're using it if you have everything in a single thread of execution, and the context doesn't need preserving, but if you don't think you can maintain containment of the code, or you pull in other libraries or code with different expectations, probably safer to have the RTOS be aware.
2021-06-21 03:12 PM
Thank you that was extremely helpful, I've had a project I've been working on that involves a lot of floating point math so I just saw this config setting that said enable fpu so I thought maybe my project was just doing it in software instead of using the fpu, thus running slower but it seem in cubeide that it is enabled by default. This has cleared up a lot for me.
2021-06-21 03:14 PM
Thank you, just trying to learn RTOS at the moment and saw this config setting and thought that one of my other projects that didnt use RTOS maybe wasnt using the FPU but it is enabled by default in the project properties.
2022-02-04 01:42 AM
Did you figure out what those define mean ? As for I am aware , The RTOS compilation fails whenever I shift the compiler flag to not use FPU. So I assumed stm adoption of FreeRTOS has some part of code dependent on FPU.
2022-02-04 05:08 AM
There's even source code for the moderately curious..