Skip to main content
David Pekin
Senior
Feb 6, 2018 8:17 PM UTC
Solved

Floating Point for STM32F303RE and IAR compiler

Posted on February 06, 2018 at 21:17

Hello,

I have  a project where I'm using some floating point variables.  When I pass the float variable into a function (passed by value) the variable inside the function shows 0.0 in the debugger.  The code compiles and links without warnings.  Maybe I'm missing some compiler define?  Below is an example:

//Prototype of callee

static int torqueControl(float Pgain, float Igain, float Dgain, int target);

void caller ()

{

float P = 1.0;

float I = 2.0;

float D = 3.0;

int target = 100;

int retval;

retval = 

torqueControl(P,I,D, target);  // called w/ PID vals

}

static int torqueControl(float Pgain, float Igain, float Dgain

, int target

)

{

// inside this function Pgain, Igain and Dgain are 0.0 

// but target is correctly 100.

}

Anyone know what might be happening here?

Thanks.

    This topic has been closed for replies.
    David Pekin
    David PekinBest answer
    Senior
    Feb 6, 2018 9:22 PM UTC
    Posted on February 06, 2018 at 22:22

    It appears that it's an issue with the IAR debugger not displaying floats correctly.  The code actually executes and passes vars correctly.

    1 reply

    David Pekin
    David PekinAuthorBest answer
    Senior
    Feb 6, 2018 9:22 PM UTC
    Posted on February 06, 2018 at 22:22

    It appears that it's an issue with the IAR debugger not displaying floats correctly.  The code actually executes and passes vars correctly.