AnsweredAssumed Answered

Float point operations (trig too) don't work on K20D (FRDM K20D50M).

Question asked by fabio ... on Apr 1, 2014
Latest reply on Jan 20, 2015 by Jorge_Gonzalez

When I have tried make an Sin Table on K20D using sin of "math.h" the execution program don't flow over it.

 

Ok. I decided not use the  "math.h", then I used const table of sin values. However when the program tries escale down the values of this table with float division and convert float to int again execution of program don't flow over casting int to float.

Piece of code:

    Motor.IncTabela = (float) 1000.0f / Motor.MaxSamples;
    Motor.Div = (((long) MAXTABELA / Motor.VMod));
    
     for (i=0, a=0; i < Motor.MaxSamples; i++, a += Motor.IncTabela ) {
         r = SinT[(int)(a + 0.5f)];
         r = r / Motor.Div;
         r = Motor.DutyZero + r;
         TabelaGerada[i] =  (uint16_t) r;
     }


I yet tried increase stack pointer size from 1024 to 2048 but don't worked (i had some problem before on S08 PA).

 

 

 

Edit:

Have anybody here?

Disabling the FTM0 overflow interrupt the code runs perfectly.

Outcomes