MPC5674F Standard Math Libraries are not working

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MPC5674F Standard Math Libraries are not working

ソリューションへジャンプ
1,632件の閲覧回数
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 解決策
822件の閲覧回数
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 返答(返信)
823件の閲覧回数
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 件の賞賛
返信
822件の閲覧回数
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.

822件の閲覧回数
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 件の賞賛
返信
822件の閲覧回数
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 件の賞賛
返信