AnsweredAssumed Answered

Floating Point Support for HCS08

Question asked by John Murphy on Nov 8, 2007
Latest reply on Nov 12, 2007 by John Murphy

Good Morning,

I have used floating-point operations in HC08 processors for many years, but this is the first time that I have tried it with an HCS08 processor.  I am trying to multiply a floating-point number and a short, and the processor simply hangs up.  I have plenty of stack space and plenty of memory.  Here are the significant lines of code:

 float Kp;

short E;

float temp;

short Rs;

 Rs = RS232RX << 2;

E =  Rs - A2D0[0];

// proportional controller

temp = Kp * E;                                    // this hangs

if(temp > 1023)

    temp = 1023;

else if(temp < -1023)

    temp = -1023;

PWM0 = (short)temp;

 The code hangs up at the line:

 E =  Rs - A2D0[0];

 I then tried to typecast E from a short to a float before the multiply:

 float Efloat;

 Efloat = (float)E;                                   // this hangs

 It hangs up on the typecast.  Interestingly, if I comment out that line and set the values to constants, the typecast from float to short works fine:

 PWM0 = (short)temp;                          // this is OK

 I am using the ansitfs library.  Any help would be greatly appreciated.

 Thank you.