Accelerometer and magnetometer FXOS8700CQ example code for MQX4.1.1

Document created by Radek Sestak Employee on Apr 13, 2015Last modified by Radek Sestak Employee on Apr 14, 2015
Version 1Show Document
  • View in full screen mode

Accelerometer and magnetometer FXOS8700CQ example code for MQX4.1.1

 

 

This example code was written for FRDM-K64F board and it is based on Tom’s bare-metal code (Thank you).

 

Content of attached zip file could be unpacked directly to examples directory (c:\Freescale\Freescale_MQX_4_1\mqx\examples\..).

It contains generated projects for CW10GCC, IAR, KDS, make and KEIL toll chains.

Note: unfortunately this example project cannot be used as source for New Project Wizard in CW10.

 

Example code uses polled I2C MQX driver for communication with FXOS8700CQ chip and it contains two options for acquisition sensors data. We can use polled (0) or interrupt (1) mode according SENSOR_USE_INTERRUPT macro definition.

In polled mode we periodically read sensor status until new data are available.

In interrupt mode sensor drives interrupt pin when new data are available.

 

Example code contains calibration functions for increasing accuracy.

Magnetometer calibration function collects data during 30s interval where we should rotate with board around z-axis in 360° range (leave board on table and rotate from north to south and back to north). It acquires approximately 3 samples per second. For change this ODR rate, we have to modify CTRL_REG1 value.

Note: Interrupt mode works correctly up to 200Hz ODR. Higher ODRs was not tested due to capacitance on interrupt pin (C56). Polled mode was tested up to 800Hz ODR (accelerometer only).

 

Example code displays received data on debug console and drives RGB LEDs according measured g’s.

 

If you are interested in more complex algorithms please refer to our Freescale Sensor Fusion Library for Kinetis MCUs.

 

I hope it helps you.

 

RadekS

Attachments

Outcomes