AnsweredAssumed Answered

float operations problems MC9S08LC60

Question asked by Augusto Lopez on Jun 1, 2016
Latest reply on Jun 1, 2016 by ZhangJennie

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!

Outcomes