Sensors Knowledge Base

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

Sensors Knowledge Base

Discussions

Sort by:
SOP Top Side Port Package_1369-01  
View full article
You saw it here first! The attached zip file contains full documentation and source code (both CodeWarrior and KDS) for Version 5 of Freescale's Sensor Fusion Library for Kinetis MCUs. The 6 and 9-axis Kalman filters have been rewritten from scratch by fusion expert Mark Pedley.  The new versions have improved dynamic tracking and at-rest stability.  All documentation has been updated, and full implementation details are included.  We continue to use the BSD 3-clause software license, so you are virtually unlimited in how you use the library.   I will note that due to the Kalman filter changes, Mark made some changes to the undocumented Kalman filter packets which are utilized by the Windows Version of the Freescale Sensor Fusion Toolbox.  This breaks compatibility with older versions of the toolbox.  I will be posting a pre-release of the new one immediately after completing this post.  The Android version of the toolbox does not make use of the Kalman filter packet, and should be forward compatible - although an updated version of that is in the works as well.   Structure of the new library is very similar to Version 4.22, which was the previous production version.  There are changes, but I don't expect anyone to have problems adapting existing projects to the new version of the library.  I think you will get improved performance if you do.   Regards, Mike Stanley
View full article
The MMA845xQ is a smart low-power, three-axis capacitive micromachined accelerometer up to 14 bits of resolution. This accelerometer is packed with embedded functions with flexible user-programmable options, configurable to two interrupt pins. Embedded interrupt functions allow for overall power savings relieving the host processor from continuously polling data. There is access to both low-pass filtered data as well as high-pass filtered data, which minimizes the data analysis required for jolt detection and faster transitions. The device can be configured to generate inertial wake-up interrupt signals from any combination of the configurable embedded functions allowing the MMA845xQ to monitor events and remain in a low-power mode during periods of inactivity. Here is a Render of the MMA845x Breakout- Board downloaded from OSH Park: And here is an image of the Layout Design for this board: In the Attachments section, you can find the Schematic Source File (.SCH), Schematic PDF File, Layout Source File (BRD), Gerber Files (GTL, GBL, GTS, GBS, GTO, GBO, GKO, XLN) and BOM for this Breakout-board. If you are interested in more designs like this breakout board for other sensors, please go to Freescale Sensors Breakout Boards Designs – HOME
View full article
All, The attached was put together in response to the posting by Andrew Hartnett.  It contains a bare-metal IAR project for 9-axis sensor fusion V7.00 on the KL25Z.  You need to have built KSDK for the KL25Z to include the ISSDK option.  Then unzip this file into your SDK_2.0_FRDM-KL25Z/boards directory.  The sample project is then located at SDK_2.0_FRDM-KL25Z/boards/frdmkl25z_virtual_shield/issdk_examples/algorithms/sensorfusion/baremetal_sensor_fusion/iar. There is also an included freertos_sensor_fusion project.  Ignore that for now.  It compiles and links, but needs more RAM than the KL25Z supplies.  I'm looking at ways to decrease the RAM requirements to fit. Regards, Mike
View full article
Hi Everyone, In this article I would like to describe a simple bare-metal example code for the new Xtrinsic FXLS8471Q digital accelerometer. I have used recently released FRDM-FXS-MULTI(-B) sensor expansion board, that features many of the Xtrinsic sensors introduced in 2013 including the FXLS8471Q, in conjunction with the  Freescale FRDM-KL25Z development platform. The FreeMASTER tool is used to visualize the acceleration data that are read from the FXLS8471Q using an interrupt technique through the SPI interface. This example illustrates: 1. Initialization of the MKL25Z128 MCU (mainly SPI and PORT modules). 2. SPI data write and read operations. 3. Initialization of the accelerometer to achieve the highest resolution. 4. Simple offset calibration based on the AN4069. 5. Output data reading using an interrupt technique. 6. Conversion of the output values from registers 0x01 – 0x06 to real acceleration values in g’s. 7. Visualization of the output values in the FreeMASTER tool. 1. As you can see in the FRDM-FXS-MULTI(-B)/FRDM-KL25Z schematics and the image below, SPI signals are routed to the SPI0 module of the KL25Z MCU and the INT1 output is connected to the PTA5 pin (make sure that pins 2-3 of J6 on the sensor board are connected together using a jumper). The PTD0 pin (Chip select) is not controlled automatically by SPI0 module, hence it is configured as a general-purpose output. The INT1 output of the FXLS8471Q is configured as a push-pull active-low output, so the corresponding PTA5 pin configuration is GPIO with an interrupt on falling edge.The core/system clock frequency is 20.97 MHz and SPI clock is 524.25 kHz. The MCU is, therefore, configured as follows. void MCU_Init(void) {      //SPI0 module initialization      SIM_SCGC4 |= SIM_SCGC4_SPI0_MASK;        // Turn on clock to SPI0 module      SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;       // Turn on clock to Port D module      PORTD_PCR1 = PORT_PCR_MUX(0x02);         // PTD1 pin is SPI0 CLK line      PORTD_PCR2 = PORT_PCR_MUX(0x02);         // PTD2 pin is SPI0 MOSI line      PORTD_PCR3 = PORT_PCR_MUX(0x02);         // PTD3 pin is SPI0 MISO line      PORTD_PCR0 = PORT_PCR_MUX(0x01);         // PTD0 pin is configured as GPIO (CS line driven manually)      GPIOD_PSOR |= GPIO_PSOR_PTSO(0x01);      // PTD0 = 1 (CS inactive)      GPIOD_PDDR |= GPIO_PDDR_PDD(0x01);       // PTD0 pin is GPIO output          SPI0_C1 = SPI_C1_SPE_MASK | SPI_C1_MSTR_MASK;     // Enable SPI0 module, master mode      SPI0_BR = SPI_BR_SPPR(0x04) | SPI_BR_SPR(0x02);     // BaudRate = BusClock / ((SPPR+1) * 2^(SPR+1)) = 20970000 / ((4+1) * 2^(2+1)) = 524.25 kHz                        //Configure the PTA5 pin (connected to the INT1 of the FXLS8471Q) for falling edge interrupts      SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;       // Turn on clock to Port A module      PORTA_PCR5 |= (0|PORT_PCR_ISF_MASK|      // Clear the interrupt flag                       PORT_PCR_MUX(0x1)|      // PTA5 is configured as GPIO                       PORT_PCR_IRQC(0xA));    // PTA5 is configured for falling edge interrupts                 //Enable PORTA interrupt on NVIC      NVIC_ICPR |= 1 << ((INT_PORTA - 16) % 32);      NVIC_ISER |= 1 << ((INT_PORTA - 16) % 32); } 2. The FXLS8471Q uses the ‘Mode 0′ SPI protocol, which means that an inactive state of clock signal is low and data are captured on the leading edge of clock signal and changed on the falling edge. The falling edge on the SA1/CS_B pin starts the SPI communication. A write operation is initiated by transmitting a 1 for the R/W bit. Then the 8-bit register address, ADDR[7:0] is encoded in the first and second serialized bytes. Data to be written starts in the third serialized byte. The order of the bits is as follows: Byte 0: R/W, ADDR[6], ADDR[5], ADDR[4], ADDR[3], ADDR[2], ADDR[1], ADDR[0] Byte 1: ADDR[7], X, X, X, X, X, X, X Byte 2: DATA[7], DATA[6], DATA[5], DATA[4], DATA[3], DATA[2], DATA[1], DATA[0] The rising edge on the SA1/CS_B pin stops the SPI communication. Below is the write operation which writes the value 0x3D to the CTRL_REG1 (0x3A). Similarly a read operation is initiated by transmitting a 0 for the R/W bit. Then the 8-bit register address, ADDR[7:0] is encoded in the first and second serialized bytes. The data is read from the MISO pin (MSB first). The screenshot below shows the read operation which reads the correct value 0x6A from the WHO_AM_I register (0x0D). Multiple read operations are performed similar to single read except bytes are read in multiples of eight SCLK cycles. The register address is auto incremented so that every eighth next clock edges will latch the MSB of the next register. A burst read of 6 bytes from registers 0x01 to 0x06 is shown below. It also shows how the INT1 pin is automatically cleared by reading the acceleration output data. 3. At the beginning of the initialization, all accelerometer registers should be reset to their default values by setting the RST bit of the CTRL_REG2 register. However, the software reset does not work properly in SPI mode as described in Appendix A of the FXLS8471Q data sheet. Therefore the following piece of the code performing the software reset should not be used. Instead, I have shortened R46 on the FRDM-FXS-MULTI-B board to activate a hardware reset. The dynamic range is set to ±2g and to achieve the highest resolution, the LNOISE bit is set and the lowest ODR (1.56Hz) and the High Resolution mode are selected (more details in AN4075). The DRDY interrupt is enabled and routed to the INT1 interrupt pin that is configured to be a push-pull, active-low output. void FXLS8471Q_Init (void) {      unsigned char reg_val = 0;          /* The software reset does not work properly in SPI mode as described in Appendix A         of the FXLS8471Q data sheet. Therefore the following piece of the code is not used.         I have shortened R46 on the FRDM-FXS-MULTI-B board to activate a hardware reset. */          /*FXLS8471Q_WriteRegister(CTRL_REG2, 0x40);     // Reset all registers to POR values          Pause(0x631);     // ~1ms delay                 do       // Wait for the RST bit to clear      {           reg_val = FXLS8471Q_ReadRegister(CTRL_REG2) & 0x40;      } while (reg_val); */                FXLS8471Q_WriteRegister(XYZ_DATA_CFG_REG, 0x00);          // +/-2g range with ~0.244mg/LSB      FXLS8471Q_WriteRegister(CTRL_REG2, 0x02);            // High Resolution mode      FXLS8471Q_WriteRegister(CTRL_REG3, 0x00);            // Push-pull, active low interrupt      FXLS8471Q_WriteRegister(CTRL_REG4, 0x01);            // Enable DRDY interrupt      FXLS8471Q_WriteRegister(CTRL_REG5, 0x01);            // DRDY interrupt routed to INT1 - PTA5       FXLS8471Q_WriteRegister(CTRL_REG1, 0x3D);            // ODR = 1.56Hz, Reduced noise, Active mode           } 4. A simple offset calibration method is implemented according to the AN4069. void FXLS8471Q_Calibration (void) {      char Xoffset, Yoffset, Zoffset;            DataReady = 0;                while (!DataReady){}      // Is a first set of data ready?      DataReady = 0;            FXLS8471Q_WriteRegister(CTRL_REG1, 0x00);     // Standby mode                   FXLS8471Q_ReadMultiRegisters(OUT_X_MSB_REG, 6, AccData);     // Read data output registers 0x01-0x06                                                      Xout_14_bit = ((short) (AccData[0]<<8 | AccData[1])) >> 2;     // Compute 14-bit X-axis output value      Yout_14_bit = ((short) (AccData[2]<<8 | AccData[3])) >> 2;     // Compute 14-bit Y-axis output value      Zout_14_bit = ((short) (AccData[4]<<8 | AccData[5])) >> 2;     // Compute 14-bit Z-axis output value                                              Xoffset = Xout_14_bit / 8 * (-1);     // Compute X-axis offset correction value      Yoffset = Yout_14_bit / 8 * (-1);     // Compute Y-axis offset correction value      Zoffset = (Zout_14_bit - SENSITIVITY_2G) / 8 * (-1);     // Compute Z-axis offset correction value                                              FXLS8471Q_WriteRegister(OFF_X_REG, Xoffset);                FXLS8471Q_WriteRegister(OFF_Y_REG, Yoffset);         FXLS8471Q_WriteRegister(OFF_Z_REG, Zoffset);                   FXLS8471Q_WriteRegister(CTRL_REG1, 0x3D);     // Active mode again }      5. In the ISR, only the interrupt flag is cleared and the DataReady variable is set to indicate the arrival of new data. void PORTA_IRQHandler() {      PORTA_PCR5 |= PORT_PCR_ISF_MASK;     // Clear the interrupt flag      DataReady = 1;     } 6. The output values from accelerometer registers 0x01 – 0x06 are first converted to signed 14-bit values and afterwards to real values in g’s. if (DataReady)     // Is a new set of data ready? {                  DataReady = 0;                                                                                                                        FXLS8471Q_ReadMultiRegisters(OUT_X_MSB_REG, 6, AccData);     // Read data output registers 0x01-0x06                                                        Xout_14_bit = ((short) (AccData[0]<<8 | AccData[1])) >> 2;     // Compute 14-bit X-axis output value      Yout_14_bit = ((short) (AccData[2]<<8 | AccData[3])) >> 2;     // Compute 14-bit Y-axis output value      Zout_14_bit = ((short) (AccData[4]<<8 | AccData[5])) >> 2;     // Compute 14-bit Z-axis output value                                            Xout_g = ((float) Xout_14_bit) / SENSITIVITY_2G;     // Compute X-axis output value in g's      Yout_g = ((float) Yout_14_bit) / SENSITIVITY_2G;     // Compute Y-axis output value in g's      Zout_g = ((float) Zout_14_bit) / SENSITIVITY_2G;     // Compute Z-axis output value in g's } 7. The calculated values can be watched in the "Variables" window on the top right of the Debug perspective or in the FreeMASTER application. To open and run the FreeMASTER project, install the FreeMASTER 1.4 application and FreeMASTER Communication Driver. Attached you can find the complete source code written in the CW for MCU's v10.5 including the FreeMASTER project. If there are any questions regarding this simple application, please feel free to ask below. Your feedback or suggestions are also welcome. Regards, Tomas
View full article
  Unibody Package with Dual Side Ports_CASE_867C_05  
View full article
You will have to add a .exe extension to the unzipped file.
View full article
This is a PDF version of the Sensor Fusion tutorial I gave at the RoboBusiness conference in Santa Clara on 24 October.
View full article
The attached is a PRE-RELEASE copy of the next version of the Freescale Sensor Fusion Library for Kinetis MCUs.  It is a pre-release because we are still working to update the datasheet and userguide to accomodate new changes.  The datasheet and user guides included in this copy are identical to the current production versions found at http://www.freescale.com/sensorfusion.  This is the first release of the library which provides ALL SOURCE CODE.  The software license is unchanged from the prior release, and is re-produced at the end of this posting.  Please do not download the file if you can't agree to these license terms.   In order to get around virus filter on the community, I've had to create a simple zip file of the fusion toolkit.  There's no installer.  Just unzip it in your directory of choice.   Pre-Release Notes for Freescale Sensor Fusion Library for Kinetis MCUs Previous production release: build 417 This release: build 420 This is a pre-release kit.  The included datasheet and user guide relate to the previous version (build 417).  Updates are in progress and will be published shortly. In the meantime, changes (at a high level) are listed below. Changes: 1.  Removed all license checking functions 2.  Fusion and magnetic calibration libraries are now included in source form.    libFusion.a is now gone.  It has been replaced by additional files in the Sources directory.  3.  Added template projects for Kinetis Design Studio 4.  Added KL46Z board support 5.  Community supported at https://community.freescale.com/community/sensors/sensorfusion 6.  The datasheet has been updated with simulated fusion metrics, code sizes and systick counts 7.  "FLASH_EU" target names have been changed to "FLASH" 8.  Changed branding from "Xtrinsic" to "Freescale".  This resulted in project prefixes  being changed from "XSFK_" to "FSFK_". 9.  Removed the Accelerometer + Magnetometer 6-axis Kalman filter (the eCompass implementation  is more efficient) 10. Debug packets are now on by default.  This enables the Sensor Fusion Toolkit for Android to startup with the correct board display on powerup. 11. The following source files have been renamed:     FSL_utils.c/.h are now drivers.c/.h     tasks_func.c/.h are now tasks.c/.h     proj_config.h is now build.h     ProcessorExpert.c is now main.c     baranski_kalman.h is now kalman.h 12. license.h has been removed 13. Added bare metal eCompass implementation for KL46Z (no MQXLite) 14. This version will not include run configurations for all KDS projects. There are too many permutations, and the tools are being regularly updated. Errata: 1.  Newer K64F Freedom boards can utilize several different versions of the OpenSDA interface.  The MBED drivers do not deal properly with flash security and can temporarily "brick" a board.  In order for the download function to work properly, the value of the NV_FSEC portion of the CPU_FLASH_CONFIG_FIELD within file name Generated_Files/CPU_Config.h must have a value of 0xFE.  Processor Expert (which generates this file) does not currently support that value.  You must make the change manually after running Processor Expert. 2.  When compiling for the first time in KDS, the tool may generate the following error message: "writing to APSR without specifying a bitmask".  This is an invalid error. Simply build a second time and the error will disappear. 3.  MQXLite 1.1.0 created via Processor Expert incorrectly handles contexts switches for the  floating point unit on the K64F.  As shipped, this does not present a problem because  floating point computations are normally completed within one sample period.  However if you add additional code to that project template, such that computations extend beyond one sample period, you will get incorrect results (there is no warning!). MQXLite 1.1.1 fixes this issue.  Check the MQX1 settings in Processor Expert to see which  version you are using. 4.  I2C transmission speeds are configured for 300KHz to 400KHz.   During the build process, it is normal to see the following:     "Warning: The device is designed to operate up to 100kHz! (SCL frequency)".     The development team routinely operates at higher I2C frequencies, although these are not necessarily guaranteed in the device datasheets.  Other warnings arise from the  MQXLite code generated by Processor Expert.  The actual fusion library is believed to be clean. Xtrinsic Sensor Fusion Library for Kinetis MCUs License: LA_OPT50 Version 20 January 2014 IMPORTANT. Read the following Freescale Software License Agreement (“Agreement”) completely.  By selecting the “I Agree” button at the end of this page, you indicate that you accept the terms of this Agreement and you also acknowledge that you have the authority, on behalf of your company, to bind your company to such terms.  You may then download or install the file. FREESCALE END-USER SOFTWARE LICENSE AGREEMENT This is a license agreement between you (either as an individual or as an authorized representative acting on behalf of your employer) and Freescale Semiconductor, Inc. (“Freescale”). It concerns your rights to use software package and any accompanying written materials (the “Software”). The Software includes any updates or error corrections or documentation relating to the Software provided to you by Freescale under this License. In consideration for Freescale allowing you to access the Software, you are agreeing to be bound by the terms of this Agreement. If you do not agree to all of the terms of this Agreement, do not download or install the Software. If you change your mind later, stop using the Software and delete all copies of the Software in your possession or control. Any copies of the Software that you have already distributed, where permitted, and do not destroy will continue to be governed by this Agreement. Your prior use will also continue to be governed by this Agreement. 1.         LICENSE GRANT. Exclusively in conjunction with Licensee’s development and sale of a product containing Freescale Xtrinsic sensor solutions (e.g., an accelerometer, magnetometer, and a gyroscope in any discrete or combined form factor) supplied directly or indirectly from Freescale (“Freescale System”), or education programs relating to the use of a Freescale System, Freescale grants to you, free of charge, the non-exclusive, non-transferable right (1) to use the Software, (2) to reproduce the Software, (3) to prepare derivative works of the Software, (4) to distribute the Software and derivative works thereof in object (machine-readable) form as part of a Freescale System, and (5) to sublicense to others the right to use the distributed Software as included within the Freescale System. If you violate any of the terms or restrictions of this Agreement, Freescale may immediately terminate this Agreement, and require that you stop using and delete all copies of the Software in your possession or control.   Any license granted above only extends to Freescale’s intellectual property rights that would be necessarily infringed by the Software as provided to you by Freescale and as used within the scope of the licenses granted.  You must advise Freescale of any results obtained including any problems or suggested improvements thereof.  Freescale retains the right to use such results and related information in any manner it deems appropriate. 2.         OTHER RESTRICTIONS.  Subject to the license grant above, the following restrictions apply: a.         Freescale reserves all rights not expressly granted herein. b.         You may not rent, lease, sublicense, lend or encumber the Software, unless otherwise expressly agreed to within this Agreement c.         You may not distribute, manufacture, have manufactured, sublicense or otherwise reproduce the Software for purposes other than intended in this Agreement. d.         You may not remove or alter any proprietary legends, notices, or trademarks contained in the Licensed Software, e.         The terms and conditions of this Agreement will apply to any Software updates, provided to you at Freescale’s discretion, that replace and/or supplement the original Software, unless such update contains a separate license. f.          You may not translate, reverse engineer, decompile, or disassemble the Software provided to you solely in object code format (machine readable) except to the extent applicable law specifically prohibits such restriction.  You will prohibit your sublicensees from translating, reverse engineering, decompiling, or disassembling the Software except to the extent applicable law specifically prohibits such restriction. 3.         OPEN SOURCE.  Any open source software included in the Software licensed herein is not licensed under the terms of this Agreement, but is instead licensed under the terms of applicable open source license(s), such as the BSD License, Apache License or the Lesser GNU General Public License.  Your use of such open source software is subject to the terms of each applicable license.  You must agree to the terms of each such applicable license, or you should not use the open source software. 4.         COPYRIGHT.  The Software is licensed to you, not sold.  Freescale owns the Software, and United States copyright laws and international treaty provisions protect the Software. Therefore, you must treat the Software like any other copyrighted material (e.g. a book or musical recording). You may not use or copy the Software for any other purpose than what is described in this Agreement. Except as expressly provided herein, Freescale does not grant to you any express or implied rights under any Freescale or third party patents, copyrights, trademarks, or trade secrets. Additionally, you must reproduce and apply any copyright or other proprietary rights notices included on or embedded in the Software to any copies made thereof, in whole or in part, if any.  You may not remove any copyright notices of Freescale incorporated in the Software. 5.         TERM AND TERMINATION.   The term of this Agreement shall commence on the date of installation or download and shall be continue until terminated in accordance with this Agreement. Freescale has the right to terminate this Agreement without notice and require that you stop using and delete all copies of the Software in your possession or control if you violate any of the terms or restrictions of this Agreement.  Freescale may terminate this Agreement should any of the Software become, or in Freescale's reasonable opinion is likely to become, the subject of a claim of intellectual infringement or trade secret misappropriation.  Upon termination, you must cease use of and destroy, the Software and confirm compliance in writing to Freescale. Upon termination, the license granted pursuant to this Agreement immediately terminates and the provisions of Sections 4 through 18 will survive any termination of this Agreement. 6.         SUPPORT.  Freescale is NOT obligated to provide any support, upgrades or new releases of the Software. If you wish, you may contact Freescale and report problems and provide suggestions regarding the Software. Freescale has no obligation whatsoever to respond in any way to such a problem report or suggestion. Freescale may make changes to the Software at any time, without any obligation to notify or provide updated versions of the Software to you. 7.         NO WARRANTY.  TO THE MAXIMUM EXTENT PERMITTED BY LAW, FREESCALE EXPRESSLY DISCLAIMS ANY WARRANTY FOR THE SOFTWARE. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. YOU ASSUME THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SOFTWARE, OR ANY SYSTEMS YOU DESIGN USING THE SOFTWARE (IF ANY). NOTHING IN THIS AGREEMENT MAY BE CONSTRUED AS A WARRANTY OR REPRESENTATION BY FREESCALE THAT THE SOFTWARE OR ANY DERIVATIVE WORK DEVELOPED WITH OR INCORPORATING THE SOFTWARE WILL BE FREE FROM INFRINGEMENT OF THE INTELLECTUAL PROPERTY RIGHTS OF THIRD PARTIES. 8.         INDEMNITY. You agree to fully defend and indemnify Freescale from any and all claims, liabilities, and costs (including reasonable attorney’s fees) related to (1) your use (including your sublicensee’s use, if permitted) of the Software or (2) your violation of the terms and conditions of this Agreement. 9.         LIMITATION OF LIABILITY.  IN NO EVENT WILL FREESCALE BE LIABLE, WHETHER IN CONTRACT, TORT, OR OTHERWISE, FOR ANY INCIDENTAL, SPECIAL, INDIRECT, CONSEQUENTIAL OR PUNITIVE DAMAGES, INCLUDING, BUT NOT LIMITED TO, DAMAGES FOR ANY LOSS OF USE, LOSS OF TIME, INCONVENIENCE, COMMERCIAL LOSS, OR LOST PROFITS, SAVINGS, OR REVENUES TO THE FULL EXTENT SUCH MAY BE DISCLAIMED BY LAW EVEN IF INFORMED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.  FREESCALE’S LIABILITY WILL IN ANY EVENT AND UNDER ANY THEORY OF RECOVERY BE LIMITED TO THE TOTAL AMOUNT RECEIVED BY FREESCALE UNDER THIS AGREEMENT. 10.       COMPLIANCE WITH LAWS; EXPORT RESTRICTIONS. You must not resell, re-export, or provide, directly or indirectly, the licensed software or direct product thereof, in any form without obtaining appropriate export or re-export licenses from the United States Government and from the country from which the export or re-export is to occur.  An export occurs when products, technology, or software is transferred from one country to another by any means, including physical shipments, FTP file transfers, E-mails, faxes, remote server access, conversations, and the like.  An export also occurs when technology or software is transferred to a foreign national in the United States, or foreign national of the country in which the business activity is taking place.  A foreign national is any person who is neither a citizen nor permanent resident of the United States, or the country in which the business activity is taking place. Furthermore, if an export/import license, permit or other government required authority (collectively referred to as “government authorization”) is required to transfer technology, software, hardware or other Freescale property to non- Freescale party(ies) and is not approved, then Freescale is not obligated to transfer the Software under this Agreement until such “government authorization” is granted.. 11.       GOVERNMENT RIGHTS.  The Licensed Software is a “Commercial Item” as defined in 48 C.F.R. §2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as such terms are used in 48 C.F.R. § 12.212 or 48 C.F.R. §227.7202, as applicable and are only licensed to U.S. Government end users with the rights as are set forth herein.. 12.       HIGH RISK ACTIVITIES.  You acknowledge that the Software is not fault tolerant and is not designed, manufactured or intended by Freescale for incorporation into products intended for use or resale in on-line control equipment in hazardous, dangerous to life or potentially life-threatening environments requiring fail-safe performance, such as in the operation of nuclear facilities, aircraft navigation or communication systems, air traffic control, direct life support machines or weapons systems, in which the failure of products could lead directly to death, personal injury or severe physical or environmental damage (“High Risk Activities”). You specifically represent and warrant that you will not use the Software or any derivative work of the Software for High Risk Activities. 13.       CHOICE OF LAW; VENUE; LIMITATIONS.  You agree that the statutes and laws of the United States and the State of Texas, USA, without regard to conflicts of laws principles, will apply to all matters relating to this Agreement or the Software, and you agree that any litigation will be subject to the exclusive jurisdiction of the state or federal courts in Texas, USA.  You agree that regardless of any statute or law to the contrary, any claim or cause of action arising out of or related to this Agreement or the Software must be filed within one (1) year after such claim or cause of action arose or be forever barred. 14.       CONFIDENTIAL INFORMATION.  You must treat the Software as confidential information and you agree to retain the Software in confidence perpetually, with respect to Software in source code form (human readable), or for a period of five (5) years from the date of termination of this Agreement, with respect to all other parts of the Software.  During this period you may not disclose any part of the Software to anyone other than employees who have a need to know of the Software and who have executed written agreements obligating them to protect such Licensed Software to at least the same degree of care as in this Agreement.  You agree to use the same degree of care, but no less than a reasonable degree of care, with the Software as you do with your own confidential information. You may disclose Software to the extent required by a court or under operation of law or order provided that you notify Freescale of such requirement prior to disclosure, which you only disclose information required, and that you allow Freescale the opportunity to object to such court or other legal body requiring such disclosure. 15.       PRODUCT LABELING.  You are not authorized to use any Freescale trademarks, brand names, or logos. 16.       ENTIRE AGREEMENT.  This Agreement constitutes the entire agreement between you and Freescale regarding the subject matter of this Agreement, and supersedes all prior communications, negotiations, understandings, agreements or representations, either written or oral, if any.  This Agreement may only be amended in written form, executed by you and Freescale. 17.       SEVERABILITY.  If any provision of this Agreement is held for any reason to be invalid or unenforceable, then the remaining provisions of this Agreement will be unimpaired and, unless a modification or replacement of the invalid or unenforceable provision is further held to deprive you or Freescale of a material benefit, in which case the Agreement will immediately terminate, the invalid or unenforceable provision will be replaced with a provision that is valid and enforceable and that comes closest to the intention underlying the invalid or unenforceable provision. 18.       NO WAIVER.  The waiver by Freescale of any breach of any provision of this Agreement will not operate or be construed as a waiver of any other or a subsequent breach of the same or a different provision.     © 2004-2014 Freescale Semiconductor, Inc. All rights reserved.
View full article
FRDM-STBC-AGM01: 9-Axis Inertial Measurement Sensor Board FRDM-KL25Z FRDM-STBC-AGM01 - Example project in KDS 3.0.0 using KSDK 1.2.0 and Processor Expert FRDM-STBC-AGM01 - Bare metal example project   FRDMSTBC-A8471: 3-Axis Accelerometer Sensor Toolbox Development Board FRDMSTBC-A8471 - Bare metal example project FRDMSTBC-A8471 - Example project in KDS 3.0.2 using KSDK 2.0 FXLS8471Q Auto-sleep with Transient threshold trigger    MPL3115A2: 20 to 110kPa, Absolute Digital (I 2 C) Pressure Sensor MPL3115A2 - Bare metal example project FRDMKL25-P3115 - Example project in KDS 3.0.2 using KSDK 2.0 https://community.nxp.com/docs/DOC-345632    MPL115A1: 50 to 115kPa, Absolute Digital (SPI) Pressure Sensor MPL115A1- Bare metal example project    FXOS8700CQ: Digital (I 2 C/SPI) Sensor - 3-Axis Accelerometer (±2g/±4g/±8g) + 3-Axis Magnetometer FXOS8700CQ - Bare metal example project FXOS8700CQ - Magnetic threshold detection function example code  FXOS8700CQ - Auto-sleep with Magnetic threshold trigger    FXLS8471Q: ±2g/±4g/±8g, 3-Axis, 14-Bit Digital (I 2 C/SPI) Accelerometer FXLS8471Q - Bare metal example project FXLS8471Q - FIFO Fill mode example code FXLS8471Q - Accelerometer vector-magnitude function example code FXLS8471Q - Accelerometer transient detection function example code FXLS8471Q - Accelerometer motion detection function example code  FXLS8471Q - Accelerometer orientation detection function example code    MMA8652FC: ±2g/±4g/±8g, 3-Axis, 12-Bit Digital (I 2 C) Accelerometer MMA8652FC - Bare metal example project MMA8652FC - Auto-WAKE/SLEEP mode   MMA8451Q: ±2g/±4g/±8g, 3-Axis, 14-bit Digital (I 2 C) Accelerometer MMA8451Q - Bare metal example project MMA8451Q - Single Tap Detection Bare metal example project FRDM-KL27Z MMA8451Q - How to build and run an ISSDK based example project    MMA8491Q: ±8g, 3-Axis, 14-bit Digital (I 2 C) Accelerometer/Tilt Sensor MMA8491Q - Acceleration data streaming using the PIT on the Kinetis KL25Z MCU   FXLN83xxQ: 3-Axis, Low-Power, Analog Accelerometer FXLN8371Q - Bare metal example project   FXAS21002C: 3-Axis Digital (I 2 C/SPI) Gyroscope FXAS21000 – Bare metal example project FXAS21002C - Angular rate threshold detection function example code   MAG3110FC: 3-Axis Digital (I 2 C) Magnetometer MAG3110FC – Bare metal example project   LM75A: Digital temperature sensor and thermal watchdog LM75A - Temperature data streaming using the PIT on the Kinetis KL25Z MCU
View full article
Session Overview Session Details Sensors Development Ecosystem   Session Hands-on Prerequisites SW prerequisites: Install required SW and tools Download following SDK, IDE and tools: 1. MCUXpresso IDE v11.9.0 or newer 2. MCUXpresso SDK v2.14.0 for FRDM-MCXN947 (while generating SDK select ISSDK and FreeMASTER middleware) 3. FreeMASTER Tool v3.2 or newer: FreeMaster Run-time Debugging tool   HW prerequisites: HW Setup and Connection  1. Know the HWs for Hands-On Training:  2. Connect HWs to get ready for Hands-On Session: Special Instructions: Attendees to bring their own Windows Laptop for hands-on training. Attendees are requested to follow this guide and come prepared with Pre-requisite SW installed on their windows laptops. Hands-on training material and boards (“FRDM-MCXN947” and “Accel 4 Click” boards) will be provided for training purpose only.        
View full article
Hands-on Training using Sensors Development Ecosystem
View full article
Hi Everyone, In this document I would like to present a very simple example code I created for the PCT2075. This I2C digital temperature sensor offers a resolution of 0.125°C with an accuracy of ±1°C over -25°C to 100°C range. It operates with a single supply from 2.7V to 5.5V and has three address pins, allowing up to 27 devices to operate on a single I2C bus without address collisions. The device also includes an open-drain output (OS) which becomes active when the temperature exceeds the programmed limits. NXP offers the PCT2075DP Arduino Shield and GUI for easy evaluation of this temperature sensor. However, I have decided to pair this demo board with the LPC55S06-EVK and create a simple example code in the MCUXpresso IDE using Config tools (Pins, Clocks and Peripherals). The connection is very straightforward. The PCT2075DP-ARD daughter board is inserted to J9, J10, J12 and J13 connectors located on LPC55S06-EVK development board. Both SDA pin (J1-5) and SCL (J1-6) lines are connected through the on-board 5.6K pull-up resistors to the FlexComm1 SDA (PIO0_13, J13_9) and SCL (PIO0_14, J13_11) pins on the LPC55S06-EVK board. The VCC pin (J6-4) is connected to the 3.3V supply voltage and the GND pin to common ground. The address select pins A0, A1 and A2 are connected to GND using jumpers between pins 2 and 3 of J7, J8 and J9, resulting in a 7-bit I2C slave address of 0x48. I created a new project in MCUXpresso IDE v11.3.0 based on SDK_2.8.2_LPCXpresso55S06 using the New project wizard:   It was not necessary to make any changes to the project and I named it LPC55S06 PCT2075 Temp reading using I2C in the wizard:   Let’s start with the Pins Config tool...:   ...to configure PIO0_13 and PIO0_14 for their I2C functions (I2C_SDA and I2C_SCL, respectively). Simply search for each pad in the Pins view:   In the diagram above, I already have PIO0_13 routed for I2C function (it is showing green). However, you may want to check the checkbox in the first column to mark the pin for routing. A dialog pops up, offering you all the possible pin multiplex functions for the pad. Scroll down through the list and select FlexComm1’s SDA function:   When you put a checkmark (“tick”) in the FC1_CTS_SDA row, the Pins Config tool routes the pad and you will see a new entry (in yellow) in the Routed Details view at the bottom of the perspective:   Follow the same procedure to route PIO0_14 for function FC1_SCL. That is already done in the screen-grab above, so I am ready to move to the Peripherals Config tool.  Use the Peripherals icon to switch to the Peripherals perspective:   The Peripherals Config tool identifies that I have set up the pads/pins for FlexComm1 to be used as I2C. But I have not yet set up the I2C peripheral, and so the tool reports a Warning:   There is a very simple fix, proposed by the tool. Select the FLEXCOMM1 warning line, and right-click to bring up a context menu:   Selecting “Initialize FLEXCOMM1 peripheral” opens a dialog where I can select the desired function for FlexComm1… in this case I want I2C configuration. So I select I2C and click [OK]:   The Peripherals Config tool displays the Flexcomm Interface I2C configuration screen. This shows all of the ‘top level’ settings for the I2C module. I configured it as follows:   As the PCT2075 does not have a data ready interrupt, I use the MicroTick (UTICK0) timer to read the Temp register periodically at a fixed rate of about 10Hz since the temp-to-digital conversion is executed every 100 ms. The UTICK0 is configured in the Peripherals Config tool as follows:   I am ready to move to the final, Clocks Config tool:   I chose to use the BOARD_BootClockFRO12M() functional group:   Then I enabled the clock to FlexComm1, since this is the FlexComm module that I use for I2C. I used the fro_12m as the clock source for FlexComm1 I2C:   Finally I enabled the fro_1m and attached the fro_1m to the UTICK timer:   All the configuration is now complete. I can click “Update Code” at the top of the screen to generate all of the necessary configuration code, accept the changes, and return to the C/C++ Develop perspective. In the UTICK0_Callback function, the Temp register is read and then the real temperature in °C is calculated as shown below. For more information on how to convert the raw values from the Temp register to real values in °C, please refer to the PCT2075 data sheet (Chapter 7.4.3).   This screenshot shows the two bytes read of the Temp register (0x00).    The calculated temperature can be watched either in the "Global Variables" window on the top right of the Debug perspective...:   ...or in the Console window:   Attached you can find the complete project developed in the MCUXpresso IDE v11.3.0. If there are any questions regarding this simple application, please feel free to ask below.   Regards, Tomas
View full article
    Objective: Getting Started guide for MPL3115 using i.MXRT1020 EVK and FRDMSTBC-P3115. This guide help enable you to: Get familiarity with NXP’s sensor toolbox ecosystem: a complete ecosystem for product development with NXP’s motion and pressure sensors targeted toward IoT, Industrial, Medical applications. Try hands-on IoT (Industrial/medical) sensor applications using NXP’s IoT sensors and IoT Sensing SDK framework (ISSDK, available as middleware component in MCUXpresso SDK). Leverage FRDMSTBC-P3115 sensor development board with i.MXRT1020 EVK to create and run example sensor applications for: NXP’s absolute pressure sensor MPL3115A2 designed for industrial applications.   Prerequisites: This Getting Started guide assumes following prior prerequisites actions to be completed: Availability of Windows 10 development PC. Availability of MIMXRT1020-EVK evaluation kit with Arduino I/O headers populated Availability of FRDMSTBC-P3115 sensor development boards. NXP’s MCUXpresso IDE v11.3.0 in installed on the development PC. mbed windows serial drivers are installed on development PC.  MIMXRT1020-EVK evaluation kit is pre-programmed with the latest OpenSDA bootloader and firmware application. Generate and download EVK-MIMXRT1020 SDK package from web based MCUXpresso SDK builder. Any serial terminal application (e.g. RealTerm) is installed on the training PC to view sensor output of ISSDK example applications.   Introduction to Sensors Developers Ecosystem: Sensor Development Toolbox is the complete ecosystem for product development with NXP’s motion and pressure sensors targeted toward IoT, Industrial, Medical applications. It encompasses a wide spectrum of sensor evaluation hardware and software tools making our sensors easy to use. Sensor Evaluation Boards Sensor evaluation boards provide a wide spectrum of enablement hardware for quick sensor evaluation and development. It includes a demonstration kit, shield development board and breakout board for motion and pressure sensors targeted toward IoT, Industrial, Medical applications. IoT Sensing SDK The IoT Sensing Software Development Kit (ISSDK) is the embedded software framework for the Sensor Toolbox ecosystem enabling NXP's digital and analog sensors platforms for IoT applications. Following are key features and benefits provided by ISSDK framework: ISSDK provides a unified set of sensor support models that target NXP’s portfolio of sensors across a broad range of NXP’s Arm ® Cortex ® -M core-based microcontrollers including NXP’s LPC, Kinetis and i.MX RT crossover platforms. ISSDK leverages latest version of MCUXpresso SDK (Kinetis, LPC and i.MX SDK) drivers and release infrastructure through MCUXpresso web. ISSDK combines a set of robust sensor drivers and algorithms along with out-of-box example applications to allow users to get started with using NXP sensors. Enables easy porting across broad range of NXP’s Arm Cortex M based Microcontrollers by using Arm CMSIS Driver APIs. Provides NXP’s sensor register definitions, register access interfaces and sensor level multiple register read/write interfaces. For more information on list of ISSDK supported sensors and development kits, refer to ISSDK Release Notes. Executing out-of-box MPL3115 examples: The out-of-box sensors (MPL3115) example projects ("evkmimxrt1020_mpl3115_examples.zip") are made available through this sensor knowledge base community page. These example projects are based on ISSDK framework using MPL3115 sensor drivers. Please refer to next sections on steps to run these out-of-box examples on MIMXRT1020-EVK attached with FRDMSTBC-P3115 sensor development board. Refer to attached "NXP_Hackathon_Sensors_GS_MPL3115.pdf" section#4, to execute out-of-box MPL3115 sensor examples using i.MXRT1020 EVK and FRDMSTBC-P3115 sensor development board. License and Copyright Information: Note: Please refer to the SW-Content-Register.txt file to get more details on the example project SW package components and applicable licenses. The example project sources are released under "LA_OPT_NXP_Software_License", users downloading this SW should carefully read the license agreements and comply.
View full article
The Freedom Sensor Toolbox-Community Edition GUI (Graphic User Interface) offers quick and easy demonstration and evaluation of the NXP sensors. The GUI can be downloaded from this link: https://www.nxp.com/design/software/development-software/sensor-toolbox-sensor-development-ecosystem/freedom-sensor-toolbox-community-edition-sensor-evaluation-and-visualization-software:SENSOR-TOOLBOX-CE NXP sensor demonstration kits compatible with the GUI are available at this link: https://www.nxp.com/design/sensor-developer-resources/sensor-toolbox-sensor-development-ecosystem/evaluation-boards:SNSTOOLBOX?tid=vanSENSOREVALUATIONBOARDS There is an User Guide available, for the Freedom Sensor Toolbox-Community Edition GUI, describing installation, running and also troubleshooting of some common problems with the GUI. Please find the User Guide at this link: https://www.nxp.com/docs/en/user-guide/STBCEUG.pdf   Figure 1. The Freedom Sensor Toolbox GUI is running correctly, Main Page When the toolbox is running correctly, after pressing the Stat button, user can observe change in individual axis in the plot,  according to the change of the individual axis on the sensor evaluated. See Figure 1. for an example with the MMA8652 accelerometer.  Note the green mark in the right down corner indicating, that the GUI and kit is working correctly. User can also observe change in Parameter Details in the Register page. See Figure 2.   Figure 2. The Freedom Sensor Toolbox GUI  is running correctly, Register Page Some users might come across an issue, where after pressing the start button, the plot in the Main Page of the Toolbox shows only zeroes for all three axis, no matter how the tilt for any of the axis, of the evaluated sensor changes. See Figure 3. Note the red exclamation mark in the right down corner, indicating an issue with the GUI. Although the Parameter Details in the Register Page shows correct values according the change of individual axis on the evaluated sensor. See Figure 4.   Figure 3. Plot in the Main Page of the GUI shows only zeroes for all three axis   Figure 4. Parameter Details in the Register Page of the GUI The issue with the wrong scaling in the Freedom Sensor Toolbox-Community Edition GUI is linked to the local preference and format on the computer. The GUIs have been designed in Chandler/USA where decimal symbol is a simple point. In Europe and in some Asian countries, it is usually a comma, hence this can cause issue with the plot. The workaround to fix the issue with the unresponsive plot in the Main Page of the GUI is to change the decimal point in Windows operational system from comma to point. Follow the instructions according the following Figures.   Figure 5. In Start menu press the Settings button   Figure 6. In the Windows Settings choose Time & Language   Figure 7. In the Time & Language window choose Region following with Additional date, time & regional settings   Figure 8. In the Clock and Region choose Change date, time or number formats   Figure 9. In Region window press Additional settings   Figure 10. In the Customize Format window change the Decimal symbol to point After changing the Decimal symbol to point, simply turn on the Freedom Sensor Toolbox GUI and the plot will show changes in the individual axis according to the change in tilt of the sensor for individual axis.
View full article
The attached is the windows installer for the latest verson of the Windows version of the Freescale Sensor Fusion Toolbox.  This version must be used with Version 5.00 of the sensor fusion library.  It is NOT backward compatible, as the structure of the undocumented Kalman filter packet has changed. Please uninstall any prior versions of the toolbox before running this installer. As in prior releases, you can reflash your Freedom boards from within the application itself.  So if you want to try the new fusion without downloading the new library and firing up KDS or CodeWarrior, you can. Version 5.00 was posted to this same board just a few minutes ago in a separate post.  It contains full documentation, including algorithm development, datasheet and user guide. Regards, Mike Stanley
View full article
Hi Everyone,   To complete the collection of simple bare-metal examples for the Xtrinsic sensors on the FRDM-FXS-MULTI(-B) sensor expansion board, I would like to share here another example code/demo I have created for the MPL3115A2 pressure sensor.   This example illustrates: 1. Initialization of the MKL25Z128 MCU (mainly I2C and PORT modules). 2. I2C data write and read operations. 3. Initialization of the MPL3115A2. 4. Output data reading using an interrupt technique. 5. Conversion of the output values from registers 0x01 – 0x05 to real values in Pascals and °C. 6. Visualization of the output values in the FreeMASTER tool.   1. As you can see in the FRDM-FXS-MULTI(-B)/FRDM-KL25Z schematics and the image below, I2C signals are routed to the I2C1 module (PTC1 and PTC2 pins) of the KL25Z MCU and the INT1 output (INT_PED) is connected to the PTA13 pin (make sure that pins 2-3 of J5 on the sensor board are connected together using a jumper). The INT1 output of the MPL3115A2 is configured as a push-pull active-low output, so the corresponding PTA13 pin configuration is GPIO with an interrupt on falling edge.     The MCU is, therefore, configured as follows. void MCU_Init(void) {      //I2C1 module initialization      SIM_SCGC4 |= SIM_SCGC4_I2C1_MASK;        // Turn on clock to I2C1 module      SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK;       // Turn on clock to Port C module      PORTC_PCR1 |= PORT_PCR_MUX(0x2);         // PTC1 pin is I2C1 SCL line      PORTC_PCR2 |= PORT_PCR_MUX(0x2);         // PTC2 pin is I2C1 SDA line      I2C1_F  |= I2C_F_ICR(0x14);              // SDA hold time = 2.125us, SCL start hold time = 4.25us, SCL stop hold time = 5.125us      I2C1_C1 |= I2C_C1_IICEN_MASK;            // Enable I2C1 module                    //Configure the PTA13 pin (connected to the INT1 of the MPL3115A2) for falling edge interrupts      SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;       // Turn on clock to Port A module      PORTA_PCR13 |= (0|PORT_PCR_ISF_MASK|     // Clear the interrupt flag                        PORT_PCR_MUX(0x1)|     // PTA5 is configured as GPIO                        PORT_PCR_IRQC(0xA));   // PTA5 is configured for falling edge interrupts                   //Enable PORTA interrupt on NVIC      NVIC_ICPR |= 1 << ((INT_PORTA - 16)%32);      NVIC_ISER |= 1 << ((INT_PORTA - 16)%32); }   2. The 7-bit I 2 C address of the MPL3115A2 is fixed value 0x60 which translates to 0xC0 for a write and 0xC1 for a read. As shown above, the SCL line is connected to the PTC1 pin and SDA line to the PTC2 pin. The I2C clock frequency is 125 kHz. The screenshot below shows the write operation which writes the value 0x39 to the CTRL_REG1 register (0x26).     And here is the single byte read from the WHO_AM_I register (0x0C). As you can see, it returns the correct device ID 0xC4.     Multiple bytes of data can be read from sequential registers after each MPL3115A2 acknowledgment (AK) is received until a no acknowledge (NAK) occurs from the KL25Z followed by a stop condition (SP) signaling an end of transmission. A burst read of 5 bytes from registers 0x01 to 0x05 is shown below. It also shows how the INT1 pin is automatically deasserted by reading the output registers.       3. At the beginning of the initialization, all MPL3115A2 registers are reset to their default values by setting the RST bit of the CTRL_REG1 register. The DRDY interrupt is enabled and routed to the INT1 pin that is configured to be a push-pull, active-low output. Further, the OSR ratio of 128 is selected and finally the part goes into Active barometer (eventually altimeter) mode.   void MPL3115A2_Init (void) {      I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG1, 0x04);          // Reset all registers to POR values           Pause(0x631);          // ~1ms delay           I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, PT_DATA_CFG_REG, 0x07);    // Enable data flags      I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG3, 0x00);          // Push-pull, active low interrupt      I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG4, 0x80);          // Enable DRDY interrupt      I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG5, 0x80);          // DRDY interrupt routed to INT1 - PTA13      I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG1, 0x39);          // Active barometer mode, OSR = 128              //I2C_WriteRegister(MPL3115A2_I2C_ADDRESS, CTRL_REG1, 0xB9);        // Active altimeter mode, OSR = 128 }   4. In the ISR, only the interrupt flag is cleared and the DataReady variable is set to indicate the arrival of new data.  void PORTA_IRQHandler() {      PORTA_PCR13 |= PORT_PCR_ISF_MASK;          // Clear the interrupt flag      DataReady = 1;   }   5. In the main loop, the DataReady variable is periodically checked and if it is set, both pressure (eventually altitude) and temperature data are read and then calculated.  if (DataReady)          // Is a new set of data ready? {      DataReady = 0;                                                                                                                         I2C_ReadMultiRegisters(MPL3115A2_I2C_ADDRESS, OUT_P_MSB_REG, 5, RawData);          // Read data output registers 0x01-0x05                    /* 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 RawData[0], RawData[1] and bits 7-6 of RawData[2].      The fractional component is located in bits 5-4 of RawData[2]. Bits 3-0 of RawData[2] are not used.*/                                             Pressure = (float) (((RawData[0] << 16) | (RawData[1] << 😎 | (RawData[2] & 0xC0)) >> 6) + (float) ((RawData[2] & 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 RawData[3].      The fractional component is located in bits 7-4 of RawData[4]. Bits 3-0 of OUT_T_LSB are not used. */                         Temperature = (float) ((short)((RawData[3] << 😎 | (RawData[4] & 0xF0)) >> 4) * 0.0625;                             /* Get altitude, the 20-bit measurement in meters is comprised of a signed integer component and a fractional component.      The signed 16-bit integer component is located in RawData[0] and RawData[1].      The fraction component is located in bits 7-4 of RawData[2]. Bits 3-0 of RawData[2] are not used */                                       //Altitude = (float) ((short) ((RawData[0] << 😎 | RawData[1])) + (float) (RawData[2] >> 4) * 0.0625; }   6. The calculated values can be watched in the "Variables" window on the top right of the Debug perspective or in the FreeMASTER application. To open and run the FreeMASTER project, install the FreeMASTER 1.4 application and FreeMASTER Communication Driver.      Attached you can find the complete source code written in the CW for MCU's v10.5 including the FreeMASTER project. If there are any questions regarding this simple application, do not hesitate to ask below. Your feedback or suggestions are also welcome.   Regards, Tomas Original Attachment has been moved to: FreeMASTER---FRDM-KL25Z-MPL3115A2-Pressure-and-temperature-reading-using-I2C-and-interrupt.zip Original Attachment has been moved to: FRDM-KL25Z-MPL3115A2-Pressure-and-temperature-reading-using-I2C-and-interrupt.zip
View full article
Here is the Installer file for the revision 4.2.0.8 of the Sensor Toolbox GUI
View full article
The MMA8491Q is a low voltage, 3-axis low-g accelerometer housed in a 3 mm x 3 mm QFN package. The device can accommodate two accelerometer configurations, acting as either a 45° tilt sensor or a digital output accelerometer with I2C bus.      • As a 45° Tilt Sensor, the MMA8491Q device offers extreme ease of implementation by using a single line output per axis.      • As a digital output accelerometer, the 14-bit ±8g accelerometer data can be read from the device with a 1 mg/LSB sensitivity. The extreme low power capabilities of the MMA8491Q will reduce the low data rate current consumption to less than 400 nA per Hz. Here is a Render of the MMA8491 Breakout Board downloaded from OSH park: Layout Design for this board: If you're interested in more designs like this breakout board for other sensors, please go to Freescale Sensors Breakout Boards Designs – HOME
View full article
Hi Everyone, In this document I would like to go through a simple example code I created for the FRDMKL25-A8471 kit using the KDS 3.0.2 and KSDK 2.0. I will not cover the Sensor Toolbox – CE and Intelligent Sensing Framework (ISF) which primarily support this kit. The FreeMASTER tool is used to visualize the acceleration data that are read from the FXLS8471Q using an interrupt technique through the SPI interface. This example illustrates: 1. Initialization of the MKL25Z128 MCU (mainly PORT and SPI modules). 2. SPI data write and read operations. 3. Initialization of the FXLS8471Q to achieve the highest resolution. 4. Output data reading using an interrupt technique. 5. Conversion of the output values from registers 0x01 – 0x06 to real acceleration values in g’s. 6. Visualization of the output values in the FreeMASTER tool. 1. As you can see in the FRDMSTBC-A8471/FRDM-KL25Z schematics and the image below, SPI signals are routed to the SPI0 module of the KL25Z MCU and the INT1 output is connected to the PTD4 pin. The PTD0 pin (Chip Select) is not controlled automatically by SPI0 module, hence it is configured as a general-purpose output. The INT1 output of the FXLS8471Q is configured as a push-pull active-low output, so the corresponding PTD4 pin configuration is GPIO with an interrupt on falling edge. The configuration is done in the BOARD_InitPins() function using the NXP Pins Tool for Kinetis MCUs. void BOARD_InitPins(void) {    CLOCK_EnableClock(kCLOCK_PortD);                                          /* Port D Clock Gate Control: Clock enabled */    CLOCK_EnableClock(kCLOCK_Spi0);                                           /* SPI0 Clock Gate Control: Clock enabled */    PORT_SetPinMux(PORTD, PIN1_IDX, kPORT_MuxAlt2);                           /* PORTD1 (pin 74) is configured as SPI0_SCK */    PORT_SetPinMux(PORTD, PIN2_IDX, kPORT_MuxAlt2);                           /* PORTD2 (pin 75) is configured as SPI0_MOSI */    PORT_SetPinMux(PORTD, PIN3_IDX, kPORT_MuxAlt2);                           /* PORTD3 (pin 76) is configured as SPI0_MISO */    PORT_SetPinMux(PORTD, PIN0_IDX, kPORT_MuxAsGpio);                         /* PORTD0 (pin 73) is configured as PTD0 */    GPIO_PinInit(GPIOD, PIN0_IDX, &CS_config);                                /* PTD0 = 1 (Chip Select inactive) */       PORT_SetPinMux(PORTD, PIN4_IDX , kPORT_MuxAsGpio);                        /* PORTD4 (pin 77) is configured as PTD4 */    PORT_SetPinInterruptConfig(PORTD, PIN4_IDX, kPORT_InterruptFallingEdge);  /* PTD4 is configured for falling edge interrupts */      NVIC_EnableIRQ(PORTD_IRQn);                                               /* Enable PORTD interrupt on NVIC */ } The SPI_INIT() function is used to enable and configure the SPI0 module. The FXLS8471Q uses the ‘Mode 0′ SPI protocol, which means that an inactive state of clock signal is low and data are captured on the leading edge of clock signal and changed on the falling edge. The SPI clock is 500 kHz. void SPI_Init(void) {    uint32_t sourceClock = 0U;    sourceClock = CLOCK_GetFreq(kCLOCK_BusClk);    spi_master_config_t masterConfig = {    .enableMaster = true,    .enableStopInWaitMode = false,    .polarity = kSPI_ClockPolarityActiveHigh,    .phase = kSPI_ClockPhaseFirstEdge,    .direction = kSPI_MsbFirst,    .outputMode = kSPI_SlaveSelectAsGpio,    .pinMode = kSPI_PinModeNormal,    .baudRate_Bps = 500000U     };    SPI_MasterInit(SPI0, &masterConfig, sourceClock); } 2. The falling edge on the CS pin starts the SPI communication. A write operation is initiated by transmitting a 1 for the R/W bit. Then the 8-bit register address, ADDR[7:0] is encoded in the first and second serialized bytes. Data to be written starts in the third serialized byte. The order of the bits is as follows: Byte 0: R/W, ADDR[6], ADDR[5], ADDR[4], ADDR[3], ADDR[2], ADDR[1], ADDR[0] Byte 1: ADDR[7], X, X, X, X, X, X, X Byte 2: DATA[7], DATA[6], DATA[5], DATA[4], DATA[3], DATA[2], DATA[1], DATA[0] The rising edge on the CS pin stops the SPI communication. Below is the write operation which writes the value 0x3D to the CTRL_REG1 (0x3A). Similarly a read operation is initiated by transmitting a 0 for the R/W bit. Then the 8-bit register address, ADDR[7:0] is encoded in the first and second serialized bytes. The data is read from the MISO pin (MSB first). The screenshot below shows the read operation which reads the correct value 0x6A from the WHO_AM_I register (0x0D). Multiple read operations are performed similar to single read except bytes are read in multiples of eight SCLK cycles. The register address is auto incremented so that every eighth next clock edges will latch the MSB of the next register. A burst read of 6 bytes from registers 0x01 to 0x06 is shown below. It also shows how the INT1 pin is automatically cleared by reading the acceleration output data. 3. At the beginning of the initialization, all FXLS8471Q registers are reset to their default values by setting the RST bit of the CTRL_REG2 register. The dynamic range is set to ±2g and to achieve the highest resolution, the LNOISE bit is set and the lowest ODR (1.56Hz) and the High Resolution mode are selected (more details in AN4075). The DRDY interrupt is enabled and routed to the INT1 interrupt pin that is configured to be a push-pull, active-low output. void FXLS8471Q_Init (void) {    FXLS8471Q_WriteRegister(CTRL_REG2, 0x40);            /* Reset all registers to POR values */    Pause(0xC62);                                        /* ~1ms delay */    FXLS8471Q_WriteRegister(CTRL_REG2, 0x02);            /* High Resolution mode */    FXLS8471Q_WriteRegister(CTRL_REG3, 0x00);            /* Push-pull, active low interrupt */    FXLS8471Q_WriteRegister(CTRL_REG4, 0x01);            /* Enable DRDY interrupt */    FXLS8471Q_WriteRegister(CTRL_REG5, 0x01);            /* DRDY interrupt routed to INT1 - PTD4 */    FXLS8471Q_WriteRegister(CTRL_REG1, 0x3D);            /* ODR = 1.56Hz, Reduced noise, Active mode */ } 4. In the ISR, only the interrupt flag is cleared and the DataReady variable is set to indicate the arrival of new data. void PORTD_IRQHandler(void) {    PORT_ClearPinsInterruptFlags(PORTD, 1<<4);           /* Clear the interrupt flag */    DataReady = 1; } 5. In the main loop, the DataReady variable is periodically checked and if it is set, the accelerometer registers 0x01 – 0x06 are read and then converted to signed 14-bit values and real values in g’s. if (DataReady)                                                        /* Is a new set of data ready? */ {    DataReady = 0;    FXLS8471Q_ReadMultiRegisters(OUT_X_MSB_REG, 6, AccData);           /* Read data output registers 0x01-0x06 */    Xout_14_bit = ((int16_t) (AccData[0]<<8 | AccData[1])) >> 2;       /* Compute 14-bit X-axis output value */    Yout_14_bit = ((int16_t) (AccData[2]<<8 | AccData[3])) >> 2;       /* Compute 14-bit Y-axis output value */    Zout_14_bit = ((int16_t) (AccData[4]<<8 | AccData[5])) >> 2;       /* Compute 14-bit Z-axis output value */    Xout_g = ((float) Xout_14_bit) / SENSITIVITY_2G;                   /* Compute X-axis output value in g's */    Yout_g = ((float) Yout_14_bit) / SENSITIVITY_2G;                   /* Compute Y-axis output value in g's */    Zout_g = ((float) Zout_14_bit) / SENSITIVITY_2G;                   /* Compute Z-axis output value in g's */ } 6. The calculated values can be watched in the Debug perspective or in the FreeMASTER application. To open and run the FreeMASTER project, install the FreeMASTER 2.0 application and FreeMASTER Communication Driver. Attached you can find the complete source code written in the KDS 3.0.2 including the FreeMASTER project. If there are any questions regarding this simple application, do not hesitate to ask below. Your feedback or suggestions are also welcome. Best regards, Tomas
View full article
clicktaleID