Shifting numbers in MMBasic


Author Message
DuinoMiteMegaAn
Senior Member

Joined: 17/11/2011
Location: Australia
Posts: 231
Posted: 11:07pm 10 Mar 2012      

The problem with shifting bytes to reconstruct a number from I2C buffer reads
is that the sign bit is missing? I know for a fact that the BMP085 16 bit constants
have some/few "signed" constants. How do I restore the sign?


BMP085_AC1 = (BMP085_buff(0)*2^8) + BMP085_buff(1)
BMP085_AC2 = (BMP085_buff(2)*2^8) + BMP085_buff(3)
BMP085_AC3 = (BMP085_buff(4)*2^8) + BMP085_buff(5)
BMP085_AC4 = (BMP085_buff(6)*2^8) + BMP085_buff(7)
BMP085_AC5 = (BMP085_buff(8)*2^8) + BMP085_buff(9)
BMP085_AC6 = (BMP085_buff(10)*2^8) + BMP085_buff(11)
BMP085_B1 = (BMP085_buff(12)*2^8) + BMP085_buff(13)
BMP085_B2 = (BMP085_buff(14)*2^8) + BMP085_buff(15)
BMP085_MB = (BMP085_buff(16)*2^8) + BMP085_buff(17)
BMP085_MC = (BMP085_buff(18)*2^8) + BMP085_buff(19)
BMP085_MD = (BMP085_buff(20)*2^8) + BMP085_buff(21)