2020-07-15 02:12 AM
If i try to create or run a function that uses a double as parameter it will end up in an UsageFault_Handler infinite loop.
Why is this and how can i fix this ?
(This prevents me even from using round() from math.h)
I use System workbench for STM32
on a Nucleo-F401RE
A simple Program like this will cause the Problem on my System:
void foo( double v ) { }
int main(void){
foo( 1.0 ) ;
return 0 ;
}
changing void in foo to something else wont help and no matter the function body it will never enter it in debug mode.
The disassembly gives:
080001f4: vldr d0, [pc, #16] ; 0x8000208 <main+24>
080001f8: bl 0x80001d8 <foo>
which will lead in the next step to
UsageFault_Handler:
08000260: b.n 0x8000260 <UsageFault_Handler>
08000262: movs r0, r0
Solved! Go to Solution.
2020-07-15 06:23 AM
You need to enable the FPU before you can use it. In STM32CubeMX generated code, this is done in SystemInit.
The FPU only supports floats, not doubles, although doubles may be implemented in software (slow).
2020-07-15 06:23 AM
You need to enable the FPU before you can use it. In STM32CubeMX generated code, this is done in SystemInit.
The FPU only supports floats, not doubles, although doubles may be implemented in software (slow).
2020-07-15 07:26 AM
Thanks TDK your answer helped me solve the problem and learn something new.
I searched for the needed FPU registers and information in the Reference-Manual but was not very successfull.
I could find some information in the CMSIS defines in core_cm4.h tho.
And ofc if HAL is used in the HAL files like suggested.