Hi!
I've a strange coding issue with multiplication of floats in IAR. Here is the code snippet:
unsigned int TEST (FS *fs){
float x0, x1, x2;
x0 = 1.0 * fs->x;
x1 = -2.0 * fs->x_1;
x2 = 1.0 * fs->x_2;
return 0;
}
The fs structure contains unsigned ints containing 10 bit ADC values. For any value of member x, the x0 = 1.0 * fs->x; row yields 2*x value in the debugger. For example x=377, then x0=756.0.
The debugger correctly translates x0 as a float. What is the problem here?