MPL3115A2 - Pressure and temperature measuring

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPL3115A2 - Pressure and temperature measuring

MPL3115A2 - Pressure and temperature measuring

Hi Everyone,

In one of my previous documents I presented a simple example code/demo that reads both the altitude and temperature data from the Xtrinsic MPL3115A2 pressure sensor and visualizes them using the FreeMASTER tool via USBDM interface. This time I would like to share another example with the MPL3115A2 programmed to measure pressure (barometer mode) and temperature. The Freescale FRDM-KL25Z board coupled with the Xtrinsic MEMS sensors board was used for this project.

The initialization of the Kinetis KL25Z128 MCU remains the same, the only small change is in the initialization of the MPL3115A2, this time the barometer mode is selected with the OSR of 128.

void MPL3115A2_Init (void)

{

     unsigned char reg_val = 0;

          

     I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG1, 0x04);               // Reset all registers to POR values

         do            // Wait for the RST bit to clear

     {

       reg_val = I2C_ReadRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG1) & 0x04;

     } while (reg_val);


     I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, PT_DATA_CFG_REG, 0x07);         // Enable data flags

     I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG3, 0x11);               // Open drain, active low interrupts

     I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG4, 0x80);               // Enable DRDY interrupt

     I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG5, 0x00);               // DRDY interrupt routed to INT2 - PTD3

     I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG1, 0x39);               // Active barometer mode, OSR = 128          

}

In the main loop, both pressure and temperature data are read and then calculated as follows.

if (DataReady)          // Is a new set of data ready?

{            

     DataReady = 0;     


     /* Read both the pressure and temperature data */

                

     OUT_P_MSB = I2C_ReadRegister(MPL3115A2_I2C_ADDRESS, OUT_P_MSB_REG);       

     OUT_P_CSB = I2C_ReadRegister(MPL3115A2_I2C_ADDRESS, OUT_P_CSB_REG);       

     OUT_P_LSB = I2C_ReadRegister(MPL3115A2_I2C_ADDRESS, OUT_P_LSB_REG);       

     OUT_T_MSB = I2C_ReadRegister(MPL3115A2_I2C_ADDRESS, OUT_T_MSB_REG);       

     OUT_T_LSB = I2C_ReadRegister(MPL3115A2_I2C_ADDRESS, OUT_T_LSB_REG);       

                

         /* Get pressure, the 20-bit measurement in Pascals is comprised of an unsigned integer component and a fractional component.

     The unsigned 18-bit integer component is located in OUT_P_MSB, OUT_P_CSB and bits 7-6 of OUT_P_LSB.

     The fractional component is located in bits 5-4 of OUT_P_LSB. Bits 3-0 of OUT_P_LSB are not used.*/

                

     Pressure = (float) (((OUT_P_MSB << 16) | (OUT_P_CSB << 8) | (OUT_P_LSB & 0xC0)) >> 6) + (float) ((OUT_P_LSB & 0x30) >> 4) * 0.25;

                

        /* Get temperature, the 12-bit temperature measurement in °C is comprised of a signed integer component and a fractional component.

     The signed 8-bit integer component is located in OUT_T_MSB. The fractional component is located in bits 7-4 of OUT_T_LSB.

     Bits 3-0 of OUT_T_LSB are not used. */

                

        Temperature = (float) ((signed char) OUT_T_MSB) + (float) (OUT_T_LSB >> 4) * 0.0625;                                                       

}        

As usual, the calculated values can be watched in the "Variables" window on the top right of the Debug perspective or in the FreeMASTER application.

MPL3115A2_Pressure&Temperature reading.JPG

MPL3115A2_FreeMASTER_Pressure&Temperature.JPG

The complete source code written in the CW 10.3 as well as the FreeMASTER project is attached to this document.

If there are any questions regarding this simple application, please feel free to ask below. Your feedback or suggestions are also welcome.

Regards,

Tomas

Labels (1)
Attachments
%3CLINGO-SUB%20id%3D%22lingo-sub-1101757%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMPL3115A2%20-%20Pressure%20and%20temperature%20measuring%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1101757%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Everyone%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIn%20%3CA%20_jive_internal%3D%22true%22%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fdocs%2FDOC-95378%22%20target%3D%22_blank%22%3Eone%20of%20my%20previous%20documents%3C%2FA%3E%20I%20presented%20a%20simple%20example%20code%2Fdemo%20that%20reads%20both%20the%20altitude%20and%20temperature%20data%20from%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.freescale.com%2Fwebapp%2Fsps%2Fsite%2Fprod_summary.jsp%3Fcode%3DMPL3115A2%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EXtrinsic%20MPL3115A2%20pressure%20sensor%3C%2FA%3E%20and%20visualizes%20them%20using%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.freescale.com%2Fwebapp%2Fsps%2Fsite%2Fprod_summary.jsp%3Fcode%3DFREEMASTER%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EFreeMASTER%20tool%3C%2FA%3E%20via%20%3CA%20href%3D%22http%3A%2F%2Fusbdm.sourceforge.net%2F%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EUSBDM%20interface%3C%2FA%3E.%20This%20time%20I%20would%20like%20to%20share%20another%20example%20with%20the%20MPL3115A2%20programmed%20to%20measure%20pressure%20(barometer%20mode)%20and%20temperature.%20The%20Freescale%20%3CA%20href%3D%22http%3A%2F%2Fwww.freescale.com%2Fwebapp%2Fsps%2Fsite%2Fprod_summary.jsp%3Fcode%3DFRDM-KL25Z%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EFRDM-KL25Z%20board%3C%2FA%3E%20coupled%20with%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.element14.com%2Fcommunity%2Fcommunity%2Fknode%2Fdev_platforms_kits%2Felement14_dev_kits%2Ffreescale_xtrinsic_evk%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EXtrinsic%20MEMS%20sensors%20board%3C%2FA%3E%20was%20used%20for%20this%20project.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20initialization%20of%20the%20Kinetis%20KL25Z128%20MCU%20remains%20the%20same%2C%20the%20only%20small%20change%20is%20in%20the%20initialization%20of%20the%20MPL3115A2%2C%20this%20time%20the%20barometer%20mode%20is%20selected%20with%20the%20OSR%20of%20128.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237f0055%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%22%3E%3CSTRONG%3Evoid%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%20%3CSTRONG%3EMPL3115A2_Init%3C%2FSTRONG%3E%20(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%237f0055%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%22%3E%3CSTRONG%3Evoid%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E)%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%7B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%237f0055%3B%22%3E%3CSTRONG%20style%3D%22font-style%3A%20inherit%3B%20font-family%3A%20inherit%3B%22%3Eunsigned%3C%2FSTRONG%3E%3C%2FSPAN%3E%20%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%237f0055%3B%22%3E%3CSTRONG%20style%3D%22font-style%3A%20inherit%3B%20font-family%3A%20inherit%3B%22%3Echar%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E%20reg_val%20%3D%200%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20color%3A%20%233d3d3d%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FP%3E%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20color%3A%20%233d3d3d%3B%22%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20I2C_WriteRegister(MPL3115A2_I2C_ADDRESS%2C%20CTRL_REG1%2C%200x04)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%22%3E%2F%2F%20Reset%20all%20registers%20to%20POR%20values%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20color%3A%20%233d3d3d%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%237f0055%3B%22%3E%3CSTRONG%20style%3D%22font-style%3A%20inherit%3B%20font-family%3A%20inherit%3B%22%3Edo%3C%2FSTRONG%3E%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%22%3E%2F%2F%20Wait%20for%20the%20RST%20bit%20to%20clear%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20color%3A%20%233d3d3d%3B%22%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20color%3A%20%233d3d3d%3B%22%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20reg_val%20%3D%20I2C_ReadRegister(MPL3115A2_I2C_ADDRESS%2C%20CTRL_REG1)%20%26amp%3B%200x04%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20color%3A%20%233d3d3d%3B%22%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%237f0055%3B%22%3E%3CSTRONG%20style%3D%22font-style%3A%20inherit%3B%20font-family%3A%20inherit%3B%22%3Ewhile%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E%20(reg_val)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20color%3A%20%233d3d3d%3B%22%3E%3CSPAN%20style%3D%22font-weight%3A%20inherit%3B%20font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20I2C_WriteRegister(MPL3115A2_I2C_ADDRESS%2C%20PT_DATA_CFG_REG%2C%200x07)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%2F%2F%20Enable%20data%20flags%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20I2C_WriteRegister(MPL3115A2_I2C_ADDRESS%2C%20CTRL_REG3%2C%200x11)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%2F%2F%20Open%20drain%2C%20active%20low%20interrupts%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20I2C_WriteRegister(MPL3115A2_I2C_ADDRESS%2C%20CTRL_REG4%2C%200x80)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%2F%2F%20Enable%20DRDY%20interrupt%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20I2C_WriteRegister(MPL3115A2_I2C_ADDRESS%2C%20CTRL_REG5%2C%200x00)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%2F%2F%20DRDY%20interrupt%20routed%20to%20INT2%20-%20PTD3%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20I2C_WriteRegister(MPL3115A2_I2C_ADDRESS%2C%20CTRL_REG1%2C%200x39)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%2F%2F%20Active%20barometer%20mode%2C%20OSR%20%3D%20128%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIn%20the%20main%20loop%2C%20both%20pressure%20and%20temperature%20data%20are%20read%20and%20then%20calculated%20as%20follows.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%237f0055%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%22%3E%3CSTRONG%3Eif%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%20(DataReady)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%2F%2F%20Is%20a%20new%20set%20of%20data%20ready%3F%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%7B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22color%3A%20%23000000%3B%20font-family%3A%20Consolas%3B%22%3EDataReady%20%3D%200%3B%20%3C%2FSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F*%20Read%20both%20the%20pressure%20and%20temperature%20data%20*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20OUT_P_MSB%20%3D%20I2C_ReadRegister(MPL3115A2_I2C_ADDRESS%2C%20OUT_P_MSB_REG)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20OUT_P_CSB%20%3D%20I2C_ReadRegister(MPL3115A2_I2C_ADDRESS%2C%20OUT_P_CSB_REG)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20OUT_P_LSB%20%3D%20I2C_ReadRegister(MPL3115A2_I2C_ADDRESS%2C%20OUT_P_LSB_REG)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20OUT_T_MSB%20%3D%20I2C_ReadRegister(MPL3115A2_I2C_ADDRESS%2C%20OUT_T_MSB_REG)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20OUT_T_LSB%20%3D%20I2C_ReadRegister(MPL3115A2_I2C_ADDRESS%2C%20OUT_T_LSB_REG)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%2F*%20Get%20pressure%2C%20the%2020-bit%20measurement%20in%20Pascals%20is%20comprised%20of%20an%20unsigned%20integer%20component%20and%20a%20fractional%20component.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20The%20unsigned%2018-bit%20integer%20component%20is%20located%20in%20OUT_P_MSB%2C%20OUT_P_CSB%20and%20bits%207-6%20of%20OUT_P_LSB.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20The%20fractional%20component%20is%20located%20in%20bits%205-4%20of%20OUT_P_LSB.%20Bits%203-0%20of%20OUT_P_LSB%20are%20not%20used.*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Pressure%20%3D%20(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%237f0055%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%22%3E%3CSTRONG%3Efloat%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E)%20(((OUT_P_MSB%20%26lt%3B%26lt%3B%2016)%20%7C%20(OUT_P_CSB%20%26lt%3B%26lt%3B%20%3CLI-EMOJI%20id%3D%22lia_smiling-face-with-sunglasses%22%20title%3D%22%3Asmiling_face_with_sunglasses%3A%22%3E%3C%2FLI-EMOJI%3E%20%7C%20(OUT_P_LSB%20%26amp%3B%200xC0))%20%26gt%3B%26gt%3B%206)%20%2B%20(%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%237f0055%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%22%3E%3CSTRONG%3Efloat%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E)%20((OUT_P_LSB%20%26amp%3B%200x30)%20%26gt%3B%26gt%3B%204)%20*%200.25%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%2F*%20Get%20temperature%2C%20the%2012-bit%20temperature%20measurement%20in%20%C2%B0C%20is%20comprised%20of%20a%20signed%20integer%20component%20and%20a%20fractional%20component.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20The%20signed%208-bit%20integer%20component%20is%20located%20in%20OUT_T_MSB.%20The%20fractional%20component%20is%20located%20in%20bits%207-4%20of%20OUT_T_LSB.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20%233f7f5f%3B%20font-size%3A%2010pt%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Bits%203-0%20of%20OUT_T_LSB%20are%20not%20used.%20*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3ETemperature%20%3D%20(%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%237f0055%3B%22%3E%3CSTRONG%20style%3D%22font-style%3A%20inherit%3B%20font-family%3A%20inherit%3B%22%3Efloat%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E)%20((%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%237f0055%3B%22%3E%3CSTRONG%20style%3D%22font-style%3A%20inherit%3B%20font-family%3A%20inherit%3B%22%3Esigned%20char%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E)%20OUT_T_MSB)%20%2B%20(%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20%237f0055%3B%22%3E%3CSTRONG%20style%3D%22font-style%3A%20inherit%3B%20font-family%3A%20inherit%3B%22%3Efloat%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E)%20(OUT_T_LSB%20%26gt%3B%26gt%3B%204)%20*%200.0625%3B%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20Consolas%3B%20color%3A%20black%3B%22%3E%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20black%3B%20font-family%3A%20Consolas%3B%20font-size%3A%2010pt%3B%20line-height%3A%201.5em%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20Consolas%3B%20color%3A%20black%3B%20font-size%3A%2010pt%3B%22%3E%7D%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAs%20usual%2C%20the%20calculated%20values%20can%20be%20watched%20in%20the%20%22Variables%22%20window%20on%20the%20top%20right%20of%20the%20Debug%20perspective%20or%20in%20the%20FreeMASTER%20application.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MPL3115A2_Pressure%26amp%3BTemperature%20reading.JPG%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MPL3115A2_Pressure%26amp%3BTemperature%20reading.JPG%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F40009i001B4CFAAD02E10A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22MPL3115A2_Pressure%26amp%3BTemperature%20reading.JPG%22%20alt%3D%22MPL3115A2_Pressure%26amp%3BTemperature%20reading.JPG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MPL3115A2_FreeMASTER_Pressure%26amp%3BTemperature.JPG%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MPL3115A2_FreeMASTER_Pressure%26amp%3BTemperature.JPG%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F39929i907C78958E193C98%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22MPL3115A2_FreeMASTER_Pressure%26amp%3BTemperature.JPG%22%20alt%3D%22MPL3115A2_FreeMASTER_Pressure%26amp%3BTemperature.JPG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThe%20complete%20source%20code%20written%20in%20the%20CW%2010.3%20as%20well%20as%20the%20FreeMASTER%20project%20is%20attached%20to%20this%20document.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIf%20there%20are%20any%20questions%20regarding%20this%20simple%20application%2C%20please%20feel%20free%20to%20ask%20below.%20Your%20feedback%20or%20suggestions%20are%20also%20welcome.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ETomas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1101757%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EPressure%20Sensors%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
No ratings
Version history
Last update:
‎09-09-2013 07:16 AM
Updated by: