I added a floating point divide to the STM32F4 discovery example from chibios 2.4.0. It throws me into the exception handler.
My code looks like this,
float xg;
short z;
z = 1000;
xg = (float)z/22.5f;
The exception happens at the divide.
Thanks in advance for your help.
STM32F4 discovery floating point
Moderators: RoccoMarco, lbednarz, tfAteba
Re: STM32F4 discovery floating point
Sorry, I should add that I am compiling using gcc 4.6 from CodeSourcery.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F4 discovery floating point
Hi,
Please also make sure to set CORTEX_USE_FPU to TRUE in chconf.h.
If you already did that then there are two possible explanations:
1) You are hitting bug 3513897. The workaround is to not put FP code in the main() function, it will be fixed in 2.4.1 (already fixed in SVN).
2) Please look at the compiled asm code, it is possible that the compiler inserts a call to a library function, codesourcery does not have yet libraries properly compiled for the CM4 FPU. If this is the case you can try the following GCC based toolchain that should have properly compiled libraries: https://launchpad.net/gcc-arm-embedded
Giovanni
Please also make sure to set CORTEX_USE_FPU to TRUE in chconf.h.
If you already did that then there are two possible explanations:
1) You are hitting bug 3513897. The workaround is to not put FP code in the main() function, it will be fixed in 2.4.1 (already fixed in SVN).
2) Please look at the compiled asm code, it is possible that the compiler inserts a call to a library function, codesourcery does not have yet libraries properly compiled for the CM4 FPU. If this is the case you can try the following GCC based toolchain that should have properly compiled libraries: https://launchpad.net/gcc-arm-embedded
Giovanni
Re: STM32F4 discovery floating point
I must be getting bug 3513897, my code is in main.
I will give the svn version a try.
I will give the svn version a try.
Re: STM32F4 discovery floating point
Turning on CORTEX_USE_FPU and moving to the svn version did the trick.
Now I am having problems with atan2f giving funny results, but I don't think it is Chibios related.
Thanks for your help.
Now I am having problems with atan2f giving funny results, but I don't think it is Chibios related.
Thanks for your help.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F4 discovery floating point
That is probably related to the library, you should give that other GCC toolchain a try.
Giovanni
Giovanni