float operations problems MC9S08LC60

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

float operations problems MC9S08LC60

Jump to solution
986 Views
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!

Labels (1)
1 Solution
695 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
696 Views
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!
-----------------------------------------------------------------------------------------------------------------------

695 Views
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 Kudos
Reply
695 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

You are welcome!

Have a great day,

Jennie Zhang

0 Kudos
Reply