I'm using the nRF52832 +SDK11.0.0 +s132. I am making a making a library with floating point calculations and compiling it with GCC. A couple of test functions are:
#define NUMAPPLES 25 float getNumApples(void) { return (float)NUMAPPLES; } float testFunc2(void) { return roundf(25.0f / (float)NUMAPPLES); } float testFunc3(void) { return roundf(25.0f / getNumApples()); }
I noticed that enabling the floating hardware in uVision/Keil sets --cpu=Cortex-M4.fp. I see that Cortex-M4.fp defaults to vfpv4-spvfpv4_sp_d16 from here. In a newer version of the doc, I only see Cortex-M4 or Cortex-M4.fp.sp listed. Cortex-M4.fp.sp defaults to FPv4-SP.
If I use the compile flags -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=soft in GCC and disable floating point hardware in uVision/Keil, then both functions give the correct value when calling them.
If I use the compile flags -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp in GCC, and enable the floating point hardware and explicitly use "--fpu=softvfp+fpv4-sp" in uVision/Keil, then both functions give the correct value when calling them.
If I use the compile flags -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard in GCC, and enable floating point hardware and explicitly use "--fpu=fpv4-sp" or do not set the --fpu option explicitly in uVision/Keil, then I get an incorrect result from testFunc3 but testFunc2 gives the correct result.
How can I get the "hard" option to work?