Found a datasheet at: - http://www.thaieasyelec.net/archives/Manual/MS5541-CM.pdf -
3,3Volt?
I checked your code with the datasheet especially the formulas for the 6 correction factors.
your code:
unsigned int c1 = result1 >> 3 & 0x1FFF;
unsigned int c2 = ((result1 & 0x7) << 10) | ((result2 >> 6) & 0x3FF);
unsigned int c3 = (result3 >> 6) & 0x3FF;
unsigned int c5 = ((result2 & 0x3F) << 6) | (result3 & 0x3F);
unsigned int c4 = (result4 >> 7) & 0x7FF;
unsigned int c6 = result4 & 0x7F;
If I read the datasheet correctly ( figure Page 12)
There is a small diff in c4 (TCO), it need another mask than in your code, but that cannot cause such a problem.
c4 is used to calculate the compensated pressure.
long c1 = (result1 >> 3) & 0x1FFF; //SENST1
long c2 = ((result1 & 0x0007) << 10) | ((result2 >> 6) & 0x03FF); // OFFT1
long c3 = (result3 >> 6) & 0x03FF; // TCS
long c4 = (result4 >> 7) & 0x01FF; // TCO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
long c5 = (result2 & 0x003F) << 6 | (result 3 & 0x003F); // Tref
long c6 = result4 & 0x007F; // TEMPSENS
If I read the formulas correctly the math needs long (32 bits) for intermediate results, so I made the correction factors long so the CPU does the math with enough bits.
(Too few bits could cause overflow => strange results)
Please give it a try..