Any Suggestions?
building a project for mpc5674F in Codewarrior 10.2
Using Software floating point support and default options from project
I did add #define _EWL_FLOATING_POINT 1 in MPC5674F_INT_RAM.prefix otherwise it won't compile.
The following function should return 45 in test... instead it returns 0.737107076324373
#include "MPC5674F.h"
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
double test;
int main(void) {
volatile int i = 0;
test = atan(1.0f) * 180 / PI;
/* Loop forever */
for (;;) {
i++;
}
}
Solved! Go to Solution.
Freescale support assisted me in with this defect. CW 10.2 libraries for MPC 5674F were defective- The #pragma work around fixed the issue, and CW10.3 beta 3 doesn't seem to exhibit the same problem.
Freescale support assisted me in with this defect. CW 10.2 libraries for MPC 5674F were defective- The #pragma work around fixed the issue, and CW10.3 beta 3 doesn't seem to exhibit the same problem.
Update: There is a bug in the Freescale libraries, and a defect has been added. A temporary workaround has been offered
It’s a codegen bug, turn off inlining for the function that makes the call :
#pragma dont_inline on
int main(void) {
volatile int i = 0;
testf = atanf(1.0f) * 4.0 / PI;
sqrtAnswer = sqrtf(4600.0f);
/* Loop forever */
for (;;) {
i++;
}
}
#pragma dont_inline reset
If the user adds the f suffix to all constants (4.0f and PI) then faster SPE codegen will happen but inlining need to be kept off.
Well the libraries are more defective the more I investigate.
2 functions I am testing with
atanf
sqrtf
Software Floating Options = atanf works, but sqrtf crashes the processor
SPE-EPFU ( HW for Single precision)= atanf gives wrong answer, but sqrtf works.
This has all been done using brand new projects created with the bareboard wizard in CW 10.2
I used SPE-EFPU Options for floating point support from the Bareboard Project wizard, if I select Software Floating point support it works.