I wrote a simple program:
#include <stdio.h>
char result_str[16];
int main()
{
float y = 3.5, x = 1.2, z;
z = x + y;
sprintf(result_str, "%f", z);
//z = sqrtf(x);
return 0;
}
At the end of the program I have a result like "4.700000" as a result_str.
But if I uncomment the string z = sqrtf(x); I have something strange: the result of sprintf operation is "0.000000" (even if processor do not execute sqrtf statement). What the trouble???
I enable the floating point module at reset ISR:
HWREG(NVIC_CPAC) = ((HWREG(NVIC_CPAC) & ~(NVIC_CPAC_CP10_M | NVIC_CPAC_CP11_M)) |
NVIC_CPAC_CP10_FULL | NVIC_CPAC_CP11_FULL);
The compiler is IAR EWARM, the platform is Stellaris EK-LM4F120XL LaunchPad.