I'm stumped by some of my variables getting clobbered on an ATTiny2313. Commenting out lines of my code one by one, the culprit seems to be the multiplication in this function:
int32_t bmp085_b5(int32_t ut) {
int32_t x1, x2;
x1 = (ut - (int32_t) ac6) * ((int32_t) ac5) >> 15;
x2 = ((int32_t) mc << 11) / (x1 + (int32_t) md);
return x1 + x2;
}
Either commenting out the x1 = ...
line (and changing the reference to x1
to ut
), or changing the multiply operation to an addition fixes the variable clobbering. To be specific, the upper byte of mc
is being zeroed. What am I missing here? It is probably something very very obvious and/or stupid, but I'm not seeing it...
The variables ac5
and ac6
are of type uint16_t
, mc
and md
are int16_t
.