When I enable FPU in compiler option,My equation result is wrong. 0 + 0 = 0 but I see -107374176 ! (byte view: 0xCCCCCCCC)
Code:
typedef struct { uint16_t year; uint8_t tA; uint8_t tB; uint8_t tc; float fl1; float fl2; }mStruct; in my function: { mStruct g1,g2; . . myload(&g1); . g.fl1+= g.fl1 + paramIn; . . . }
RTOS is used too(RTX with cmsis_os). Everything is OK without FPU option.
What is wrong?
Thanks.
You forgot to show us how you got your results. Where would we see any code doing 0+0? The only addition we see are an addition where we aren't allowed to see where the variables gets their values - and one of the variables even have an unknown data type.
How would we know that myload() actually does what it should?
And where would we see any code trying to present the result?
Another thing:
g.fl1+= g.fl1 + paramIn;
The above is a quite strange formula. Are you sure that you intended to use += and not = or was your goal:
g.fl1 = g.fl1 + g.fl1 + paramIn;
Or maybe you intended:
g.fl1 += paramIn;
sorry.
myload function load last saved value from eeprom and I set fl1 member to zero for testing in this function.
Its my goal:
g.fl1 = g.fl1 + g.fl1 + paramIn; or g.fl1=2*g.fl1 + paramIn ;
g.fl1 is zero when myload function executed. pramIn is zero too(passed parameter to this function.)
result must be zero in this condition but I see that negative large number when fpu is enable.
Thanks again.
When I change my local struct (g1) to static everything is OK.
Is this the alignment problem?