MPC5674F Standard Math Libraries are not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MPC5674F Standard Math Libraries are not working

跳至解决方案
1,630 次查看
timias
Contributor IV

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++;

  }

}

 

 


标签 (1)
0 项奖励
回复
1 解答
820 次查看
timias
Contributor IV

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.

在原帖中查看解决方案

0 项奖励
回复
4 回复数
821 次查看
timias
Contributor IV

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.

0 项奖励
回复
820 次查看
timias
Contributor IV

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.

820 次查看
timias
Contributor IV

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

0 项奖励
回复
820 次查看
timias
Contributor IV

I used SPE-EFPU Options for floating point support from the Bareboard Project wizard, if I select Software Floating point support it works.

0 项奖励
回复