MPL115A1- Bare metal example project

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

MPL115A1- Bare metal example project

MPL115A1- Bare metal example project

This time, I would like to share with you an example project using the MPL115A1, the NXP digital barometer.

 

The MPL115A1 is a simple barometer with digital output for cost-effective applications. It employs a MEMS pressure sensor with a conditioning integrated circuit to provide accurate pressure data. An integrated analog-to-digital converter (ADC) provides digitized temperature and pressure sensor outputs via serial peripheral interface (SPI), with bus speeds up to 8 Mbps.

 

You may find more information at: MPL115A: 50 to 115kPa, Absolute Digital Pressure Sensor.

 

I created this project using the FRDM-KL25Z platform and the MPL115A1 absolute digital pressure sensor. The complete source code is written in KDS IDE. You may find the complete project attached to this post.

 

This document gives you an introduction of the MPL115A1 pressure sensor as well as the different configurations and guides you through the initialization process and how to appreciate the demonstration.

 

Introduction to the example project

This example is based on the application note AN3785 -How to Implement the Freescale MPL115A Digital Barometer. I recommend using it as a reference.

 

Through this example project, the MCU is configured to use the SPI interface and the PIT module. The local pressure is read every second.

 

There are MPL115A1 SPI commands to read coefficients, execute Pressure and Temperature conversions, and to read Pressure and Temperature data. The sequence of the commands for the interaction is given as an example to operate the MPL115A1.

203568_203568.pngpastedImage_5.png

Initialization of the MKL25Z128 MCU.

203569_203569.jpgcode.jpg

 

Sequence flow chart.

The MPL115A1 interfaces to a host (or system) microcontroller in the user’s application. All communications are via SPI. A typical usage sequence is as follows:

203582_203582.pngpastedImage_4.png

Every stage of the flow chart is applied on this example and explained below.

 

  1. Reading coefficient data

These are MPL115A2 SPI commands to read coefficients. The coefficients are usually stored in the host microcontoller local memory but can be re-read at any time.

 

Reading of the coefficients may be executed only once and the values stored in the host microcontroller. It is not necessary to read this multiple times because the coefficients within a device are constant and do not change.

 

Read Coefficients:

[CS=0], [0x88], [0x00], [0x8A], [0x00], [0x8C], [0x00], [0x8E], [0x00], [0x90], [0x00], [0x92], [0x00], [0x94], [0x00], [0x96], [0x00], [0x00], [CS=1]

203583_203583.pngpastedImage_1.png

Once the coefficients are obtained, they are computed inside the MPL115A1_Read_Preassure function.

 

 

  1. Data conversion

This is the MPL115A2 SPI commands to start conversion.

 

This is the first step that is performed each time a new pressure reading is required which is initiated by the host sending the CONVERT command. The main system circuits are activated (wake) in response to the command and after the conversion completes, the result is placed into the Pressure and Temperature ADC output registers.

 

Start conversion:

[CS=0], [0x24], [0x00], [CS=1], [13 ms Delay]

 

203584_203584.pngpastedImage_2.png

 

This is the MPL115A2 SPI commands to read raw temperature and pressure data.

 

 

Start Read raw data:

[CS=0], [0x80], [0x00], [0x82], [0x00], [0x84], [0x00,] [0x86], [0x00], [0x00], [CS=1]

203585_203585.pngpastedImage_3.png

 

  1. Compensated pressure reading

Once the raw rata is obtained, the compensation procedure is applied as follow:

203586_203586.jpgformula.jpg

 

 

Local pressure

 

Once the steps mentioned above are followed, the MPL115A1_Read_Preassure function returns the local pressure value into the local_pressure variable.

I recommend evaluating this variable in order to know the final result.

 

203587_203587.pngpastedImage_2.png

 

I hope you find the information useful and funny.

 

Regards,

David

 

Labels (1)
Attachments
No ratings
Version history
Last update:
‎11-10-2017 12:09 PM
Updated by: