This project introduces on interfacing e14 xtrinsic sensor board to Kinetis freedom board K64F. As we know xtrinsic sensor board is having pin compatible of arduino interface and K64F is also having arduino compatible interface so both the board are one-to-one pluggable. The interface looks like the picture shown below. This project polls data from accelerometer and displays in ‘g’s, polls data from magnetometer in ‘uT ‘, Getting pressure and temperature data in kPa and degrees Celsius.
Before we begin make sure below requirements are there as setup
Required Hardware and Software:
- Kinetis Design Studio 3.0
(download link: KDS 3.0)
- Kinetis Software Development Kit (KSDK-v1.2.0)
(Download Link Kinetis SDK 1.2 Mainline )
- FRDM-K64F Board configured with JLink Debugger
(The firmware can be downloaded here: Firmware download)
Or loaded with PE micro openSDA driver
This project operates in 4 modes or state machines Standby mode, Accelerometer mode , Magnetometer mode, Pressure/Temp mode. All these modes can be transited through successive button press (SW3). You can see a LED_Red is on in Accelerator mode and Green Led is switched on while in Magnetometer mode and Blue LED is switched on in Pressure mode. The sensor data’s are been sent to UART port and can be seen on HyperTerminal.
Little bit on Xtrinsic sensor board:
The sensor board comes equipped with three of Freescale's new-generation XTRINSIC MEMS sensors. The MPL3115 (U1) is designed for accurate measurement of temperature and pressure, the MAG3110 (U2) for detection of magnetic fields, and the MMA8491 (U3) for measurement of physical positions.
The MPL3115 is a high-precision sensor used to provide accurate pressure and altitude data. It features an adjustable sampling rate, ultra-low power consumption and intelligent functions, suitable for applications such as mobile, medical and security devices. MPL3115 is able to provide digitized output, two separated wake-up interrupts, minimum/maximum threshold mechanism, and autonomous data acquisition. The self data processing ability of the MPL3115 reduces the need for communication with MCUs, which reduces overall system power consumption.
The MAG3110 is a small, low-power, digital 3-axis magnetometer featuring a wide measurement range. It can measure magnetic fields (the overlapped fields consisting of the geomagnetic field and the fields created by components on PCB) on each of the 3 axes in the position where it is placed. The MAG3110 features an I2C serial interface, and is capable of measuring magnetic fields of up to 10 Gauss with an output data rate up to 80Hz. The output data rate can vary depending on the sampling intervals and may be adjusted from 12ms to several seconds.
The MMA8491Q is a low voltage, 3-axis low-g accelerometer housed in a 3 mm by 3 mm QFN package. The device can accommodate two accelerometer configurations, acting as either an easy to implement 45° Tilt Sensor or a digital (I2C) output accelerometer. In the 45° Tilt Sensor mode, it offers extremely easy board implementation by using a single line of output per axis. In the digital output mode, 14-bit ±8g raw data can be read from the device with high 1 mg/LSB sensitivity. The extreme low power capabilities of the MMA8491Q reduce the low data rate current consumption to less than 400 nA per Hz.
As per our stated requirement the modules that are been created in this project are:
- Console IO: for UART communication
- I2C_LDD: required for I2C communication
- ExtInt_LDD: external interrupt signal required for MAG3110 sensor
- ExtInt_LDD: external interrupt signal required for MPL3115 sensor
- TimerInt_LDD: Timer interrupt for every 1 ms generated
- TimerUnit_LDD: This is an referenced component required for timer interrupt generation
- BitIO_LDD: Bit i/o signal required for enable pin of Accelerometer
- ExtInt_LDD: external interrupt signal interfaced to switch SW3 for user interface
- LEDbit: This component is for Red LED
- LEDbit: This component is for Green LED
- LEDbit: This component is for Blue LED
The hardware connections are as shown below:
- ConsoleIO is connected to
UART0->TX = PTB17
UART0->RX = PTB16
- I2C_LDD is connected to
- MAG3110 interrupt pin is connected to PTD1
- MPL3115 interrupt pin is connected to PTD7
- Accelerometer enable pin is connected to PTA0
Executing the program:
Import the attached project to your workspace from here
Select the project location and open it.
Build the project as shown below:
Our project builds with no error as shown below
Next we will proceed for debugging the application code:
click on Debug configuration and select our project:
My board is loaded with P&E micro opensda driver and i will be selecting related option as shown:
Open the hyperterminal window of your choice:
I have putty in my system, provide the configuration for the serial terminal as shown:
Now execute the project by pressing the “resume” button
You can open the hyperterminal window
It will ask you to press “switch-3” present on board.
By pressing first time it displays the accelerometer data and red led is switched “on”
press the switch again to display magnetometer data and Green LED is switched ‘on’
press the switch again to display the pressure and temperature data, Blue led is switched ‘on’
You can see the snap shot of the hyperterminal output:
Happy executing the Xtrinsic sensor interfacing to K64F freedom board:
I have enclosed the binaries and project folder for quick reference and evaluation.