AnsweredAssumed Answered

MPL115A fixed point question

Question asked by william sell on Sep 5, 2009
Latest reply on May 15, 2014 by Jack Everett
I am trying to make sense of the coefficients I receive from the pressure sensor MPL115A.  I can successfully access the IIC bus and get the data, but the algorithm provided in the AN3785 does not appear to work (at least for me).  Closer inspection of the comments raises some questions.  For example, the coeff C11 is described as a signed number with no int bits and 10 frac bits.  There are 11 pad zeros.  So I think the number looks like this:

S0.00000000000 F10 F9 F8 F7 F6 F5 F4 F3 F2 F1 F0

To me the representation of this number is s(0,21), but the comment says s(16,27).

When I extract the data from the sensor, C11 is given as 0x0340.  This is a 2's compliment number and only the first 11 bits are used (the 10 frac bits and the sign bit).  So if I convert this to a real number (not something I would do in the processor, but just to see if I am understanding this correctly),  I get

S0.00000000000 0000 0011 010x xxxx

this gives 2^-17+ 2^-18 + 2^-20 = 0.00001239776611328125

this is the extent of my understanding, and I wonder if someone could confirm I have done this correctly.  In addition, as the algorithm in AN3785 keeps everything in fixed point, I cannot see where lt1 (a 32-bit value) can be assigned C11 and this be correctly justified.  When I assign 0x0340 to the long I get

lt1    0x00000340
= 0000 0000 0000 0000 0000 0011 010x xxxx

so you can see I am not correctly aligned as per the bit-width specifications.  The following is the code snippet.  The comments make no sense to me, so any clarification you could prrovide would be most helpful

 //******* STEP 1 c11x1= c11 * Padc
 lt1 = (S32)sic11;                  // s(16,27)    s(N,F+zeropad) goes from s(11,10)+11ZeroPad = s(11,22) => Left Justified = s(16,27)

Thanks

-Bill

Outcomes