Problem using math library functions

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

Problem using math library functions

2,204 次查看
puneetgautam
Contributor I

I am using CW 10.2v with MQX 3.8. I am using Kinetis K-61 microcontroller.

I am not able to use any of the math functions, despite including the header file.

The function i want to use is not getting mapped to the same in math.h header file. No build error is there.

 

Do i need to do any modification in the project? How to get over this problem.?

Please help!!

 

Regards

Puneet

标签 (1)
0 项奖励
回复
6 回复数

1,622 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi bel.

I ever used CW 10.2v and MQX 3.8 on k60 board this way:

set in user_config.h MQX_INCLUDE_FLOATING_POINT_IO 1. You can find this file in the next path:

C:\Program Files\Freescale\Freescale MQX 3.8\config\twrk60n512

After this you must recompile K60 BSP and PSP libraries. You can find the projects to recompile these libraries in the next paths:

C:\Program Files\Freescale\Freescale MQX 3.8\mqx\build\cw10\bsp_twrk60n512

C:\Program Files\Freescale\Freescale MQX 3.8\mqx\build\cw10\psp_twrk60n512

Finally, in your applications project, you must change your library model to c9x in your project porperties as you have already done. But you must also change print format and scan format to int_FP. And change IO Mode to Buffered.

Dont forget to include #include  in your source file where you are using math file.

Best Regards,

Zhang Jun

===============================================

this answer is for you, if it helps, please click on "Correct Answer" button.

===============================================

0 项奖励
回复

1,622 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Puneet,

About your problem , you can refer to this CW 10.6 Kinetis - "incompatible implicit declaration" of all math.h functions? .

You can try , even thought the version not the same , I think the principle is the same.

Hope it helps

Best Regards

ALice

------------------------------------------------------------------------------------------

If this post answers your question, please click the Correct Answer button.

0 项奖励
回复

1,622 次查看
puneetgautam
Contributor I

Hi

Actually , i am not using MQX. Its just a bareboard project using K-61 controller.

I have tried the solution posted above but that doesnt seem to work.

I am not getting any errors. I think CW is not able to provide support for Floating point.

In ansi_prefix.ARM.h file, I have tried to set the following flags:

1. _EWL_FLOATING_POINT

2. _EWL_FLOATING_POINT_PRINTF_SCANF to 1.

The problem remains the same. It is not recognizing any math functions.

Please help!!

Regards

Puneet

0 项奖励
回复

1,622 次查看
trytohelp
NXP Employee
NXP Employee

Hi Puneet,

I don't have anymore the MCU v10.2 installed on my PC.

I've performed some tests with the config:

          - MCU v10.6

          - Multilink Universal  Rev B,

          - TWR-K60D100M (Based on K60DN512)

My example is using the fabs().

I can build it and the application is running fine on board.

Attached you will find the example.

Have a great day,
Pascal
Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,622 次查看
puneetgautam
Contributor I

Hi pascal

I have not tried CW 10.6 but i tried to build the same application using CW v10.5. I could not find any solution for the same.

See, I am able to build my application and fuse it with Microcontroller board.

But the problem is that i am not getting the correct results as expected.

The math functions like sin, cos, asin , acos and even stdlib functions like atof are not working correctly.

This is happening because these function names are not getting mapped to their definitions provided in the header files <math.h> and <stdlib.h>.

But i am able to use atoi and atol functions defined in <stdlib.h>.

Maybe , some issue with the floating point support.

Pls help !!

Regards,

Puneet Gautam

BEL

0 项奖励
回复

1,622 次查看
trytohelp
NXP Employee
NXP Employee

Puneet,

I'm not using MQX project.

Based on the EWL C Reference.pdf manual, I've created an example using the sin().

      Refer to the 13.5.6 sin() page 98

the result should be 0.8387.

In the debugger I see:

It seems it's working on my side.

Attached the new example.


Have a great day,
Pascal
Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复