Hello,
I've download the example source tmp006.zip from this thread:
e2e.ti.com/support/sensor/temperature_sensors/f/243/t/251827
In the TMP006FixedPoint.c file in line 130, there is the following expression:
fvout = ((c2 * (fvout * fvout) >> 31) >> 12) + (fvout >> 5);
How this line of code is executed depends on the compiler and needs additional parenthesis to specifiy the correct execution order of the operands.
I'm not sure whether it is:
fvout = (( (c2 * (fvout * fvout)) >> 31) >> 12) + (fvout >> 5);
or:
fvout = ((c2 * ((fvout * fvout) >> 31)) >> 12) + (fvout >> 5);
In words, I'm not sure if the quadrated fvout should be shifted first and then multiplied by c2 or be first multplied with c2 and the result shall be shifted.
Trying both variants produces very similiar results so I'm asking here for help.
Thank you in advance.