Joern Katzorke

Function Return and Variable Disappear

Discussion created by Joern Katzorke on Aug 5, 2010
Latest reply on Aug 9, 2010 by Daniel Lundin



i got a problem getting me crazy :smileywink:


i got a function:



float FUNCTIONS_convolution(uint16_t x[], uint16_t y[]){     uint8_t i = 0;  float x_bar = 0.00;  float y_bar = 0.00;  float sigma_x = 0.0;  float sigma_y = 0.0;  float sigma_xy = 0.0;  float rho = 0.0;  ...  some crazy calculations   ...  sigma_xy = (sigma_xy / 9.0);  rho = (sigma_xy / (sigma_x * sigma_y));    return rho;}



and i call it from my main function with:



/* Write your local variable definition here */  uint16_t x[10] = {1,2,3,4,5,6,7,8,9,10};  uint16_t y[10] = {1,2,3,4,5,6,7,8,9,10};  float convolution = 0.0;  float temp = 0.0;    /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/  PE_low_level_init();  /*** End of Processor Expert internal initialization.                    ***/  /* Write your code here */    ...  some initialisation stuff  ...    while(1){        if(process == CONVOLUTION)    {      convolution = FUNCTIONS_convolution(x, y);            temp = 2*convolution;            if(temp <= convolution)      {        FUNCTIONS_usb_send_byte('O');      }            process = IDLE;    }      }


now my problem is that in my function the calculations are done up to the last few lines...

sigma_xy has a value, but it keeps it value even after division.

after that rho is not calculated and stepping in the tru time simulator skips the calculation and return value.

in the simulator (P&E Debugger, software running on hardware) the variables rho, convolution and temp are not shown.

the if case is not correct, its just a tryout to tell the compiler that i need that variables :smileywink:

whats wrong and how can i tell the compiler not to cut my variables away :smileywink:


im using codewarrior 4.7


Compiler throws a warning: C12056: SP debug info incorrect because of optimization or inline assembler


im not using inline assembler, maybe from the includet math.h?