This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FPU problem

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.

Parents
  • 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;
    

Reply
  • 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;
    

Children