float operations problems MC9S08LC60

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

float operations problems MC9S08LC60

跳至解决方案
714 次查看
augustolopez
Contributor I

Hi everybody, i'm quite new with freescale/nxp mcu's and i'm having a problem using flaoting point arithmetic. The problem is that some float operations are writing trash over some other variables that i don't want to modify. The operations are done well and fast with good results but they write trash in some memory adresses that are occuped by other variables. This happens, for example with theese operations:

 

f1=floor(bufferTX); f2=fabs(bufferTX - f1); i1=(int)f1; i2=(int)10*f2; 

or with:

t/=10; t=0.000006*pow(t,3)-0.00081*pow(t,2)+0.3*t-20;

f1,f2, bufferTX and t are floats, i1 and i2 ints.

 

What could be happening? I've added ansis.lib to the project and i'm using CodeWarrior 6.1with DEMO9S08LC60 kit.

 

Any suggestion will be very helpful.

 

Thanks!

标签 (1)
1 解答
423 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Normally this issue may because of the stack overflow. please increase the stack size in prm file then test it again.

If the problem persists, please upload your demo project here, I can check it directly from my side. thanks!


Have a great day,
Jennie Zhang

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

在原帖中查看解决方案

3 回复数
424 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Normally this issue may because of the stack overflow. please increase the stack size in prm file then test it again.

If the problem persists, please upload your demo project here, I can check it directly from my side. thanks!


Have a great day,
Jennie Zhang

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

423 次查看
augustolopez
Contributor I

Hi Jennie Zhang, thank you very much for the answer!

I've duplicated the Stack size and now everything works fine!

Regards

0 项奖励
回复
423 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

You are welcome!

Have a great day,

Jennie Zhang

0 项奖励
回复