floating to fraction

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

floating to fraction

跳至解决方案
3,110 次查看
ahnjoseph
Contributor III

MCU : s12zvl

CW:  10.6

 

  I need to convert a floating point variable ram to fraction value for Using Fraction Lib

 

  float f_t1;

  tFrac16 test_frac1,test_frac2  ;

 

 

  f_t1=0.5;

  test_frac1 = FRAC16(0.5); // <--- O.K

  test_frac1 = FRAC16(f_t1) ; // Compile Err

 

 

How can i do ?

标签 (1)
0 项奖励
回复
1 解答
2,796 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Ahn,

I built your project from my side, I got error message:

pastedImage_0.png

this is because symbols such as __fcmp are supported in floating library only. while this project use integer library ansii.lib which doesn't support symbols.

So Fiona is correct, change ansii.lib(c_no_float support library) to ansif.lib(c_float support library) can correct the problem.

pastedImage_3.png

for HCS12z library usage of, see below:

pastedImage_2.png

my modified project is attached.

can this help you?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

4 回复数
2,796 次查看
TICS_Fiona
NXP Employee
NXP Employee

Hello Ahn

Please choose the floating Point Library instead. Please open the Project Properties from ‘Project’ menu-> Properties. Then go to C/C++ Build-> Settings, under <Tool Settings> tab, go to S12Z Linker->Input,  please replace :

"${MCUToolsBaseDir}/S12lisa_Support/s12lisac/lib_small/ansii.lib"

With:

"${MCUToolsBaseDir}/S12lisa_Support/s12lisac/lib_small/ansif.lib"

lib.png

I also attached a simple example project for using FRAC16 macro.

Best Regards

Fiona Kuang

Technical Information & Commercial Support

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

Note: If this post answers your question, please click the Correct Answer button. Thank you!

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

2,796 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Ahn,

what error message do you have? can you please send a screenshot of it?

to solve the problem faster, can you please send your demo project here thus i can work on your issue directly. thanks!


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
2,797 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Ahn,

I built your project from my side, I got error message:

pastedImage_0.png

this is because symbols such as __fcmp are supported in floating library only. while this project use integer library ansii.lib which doesn't support symbols.

So Fiona is correct, change ansii.lib(c_no_float support library) to ansif.lib(c_float support library) can correct the problem.

pastedImage_3.png

for HCS12z library usage of, see below:

pastedImage_2.png

my modified project is attached.

can this help you?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,795 次查看
ahnjoseph
Contributor III

Thank you Fast service

Pls check attached Proj.

Thanks your kindly service

Best Regards

……………………………………

Joseph Ahn(안연수)

Assistant Software Design Manager

Avnet Electronic Marketing.

Joseph.ahn@avnet.com<mailto:Joseph.ahn@avnet.com>

……………………………………

12th Floor, KBS Media Center, Maebongsan-ro 45 (Sangam-dong),

Mapo-gu, Seoul, 121-915, Korea

Direct:

82-2-6277-6395

Fax:

82-2-761-2133

0 项奖励
回复