2023-01-04 05:12 PM
Hello,
I am new to STM32 MCU and right now using a 170MHz STM32G474 MCU for my project. I did a test today and found out the float number calculation speed of the MCU is quite slow.
It takes 6.3us to finish the calculation in Fig.1. (I set a GPIO pin high before the calculation starts and set it to low after the calculation). ADC_Value[] is integer and the rest variables are float. The speed is just too slow to believe.
The clock is set to be 170MHz. Am I missing something in the project setting (shown in Fig2 and Fig3)? Is this the real calculation speed for the MCU?
I know that in TI C2000 DSP, we can include a Scalar Factor Optimizer Library header to speed up the float calculation (SFO_V8.h). Does the STM32 DSP have the similar headers? Thanks.
Solved! Go to Solution.
2023-01-04 09:37 PM
Try to change ALL const value to float as said by Tesla...
For example use 0.2f instead of 0.2 (the Last one is a double !)
If the real app work on large buffer of adc value, consider loop unrolling coding optimisation instead of calling Adc_management() for each set of sample.
2023-01-04 06:49 PM
If you don't need mantisse, why not stick to fractional binary like Q31, or calculate with pre.multiplied values by 1024? FMAC I guess is an IP to contemplate.
Otherwise, check your project settings, use of FPU vs sw emulated library, compiler optimisatipn mode, etc....
2023-01-04 07:18 PM
Check the generated code, check it's using float constants
2023-01-04 09:37 PM
Try to change ALL const value to float as said by Tesla...
For example use 0.2f instead of 0.2 (the Last one is a double !)
If the real app work on large buffer of adc value, consider loop unrolling coding optimisation instead of calling Adc_management() for each set of sample.
2023-01-04 10:18 PM
2023-01-05 09:38 AM
Thanks for the example. I changed all the numbers to float format and used the -Ofast optimizer in the GCC Compiler Optimization setting. The calculation time length is reduced by 85% -- a much reasonable number. Thanks!
2023-01-08 05:39 PM