I searched a few posts on this forum (especially about powf()), but it seems, that nobody had similar problem like me. I am not professional, so it can be some basic mistake which I am not aware about...
I am using the MCU - MC9S08JM60, with OpenSource BDM, CodeWarrior IDE v5.9.0 - Build 2830 (install file CW_MCU_V6_2_SE.exe, downloaded from feescale), Processor Expert v3.06 for freescale HC(S)08/RS08/CFV1, CW plugin IDE v4.26.
Until I am using powf() function, everything working fine. But when I call the powf function, it unpredictably change variables outside this function. I found it out by stepping the program in debugging mode. I have included #include <math.h> and I added an ansifs.lib to my project since without it there was some errors about not defined float (or something...).
I am trying calculate altitude, so it have to be accurate:
unsigned int cislo;
unsigned int pressure_value;
case 2: //Altimeter:
i2c_RecvBlock(i2c_data_r,3,i2c_cnt_r); // I2C recieve data ffrom I2C
pressure_value=pressure_value+i2c_data_r+32767; // 0-65535 -> 40-116kPa
// equation dividied in parts
altitude = 34720 + pressure_value;
altitude = powf(altitude, 0.190263236508); // There is the problem...
altitude = ((-5.08604881782 * altitude) + 44.33076923)*10000;
cislo = altitude/1;
NumberToString(cislo, ConvertedLong); // convert cislo to string
LcdStr(FONT_1X, ConvertedLong); // display on LCD
case 3: //Pressure:
There is showed the function which causing the problem and I skipped varibles and definition which are not urgent in this case...
After powf() calculate the altitude, it change not only the altitude value, but it change also another variables, but I have no Idea why, I was trying computing it in steps with help of another variables, but the result was the same after powf() function...
there is the screen from debuger debuger.png
If is there anybody with some clue what could be wrong, I would really appreciate help! Thanks for any advice and sorry about my English.