Sensors Knowledge Base

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

Sensors Knowledge Base

Discussions

Sort by:
SOP Dual Side Port Package_1351-01
View full article
        The FXTH87xx is a sensor for use in applications that monitor tire pressure and temperature. It contains the pressure and temperature sensors, an X-axis and a Z-axis accelerometer, a microcontroller, an LF receiver and an RF transmitter all within a single package.        Recently a customer requests help to connect FXTH87xx with Infineon TPMS receiver. We connect them each other through some testing and verification finally. The target of this document description is to replace external emitter with FXTH87xx. This document take an example to offer the users a method how to detect and decode an unknown sensor Emitter Packets using instrument provided by R&S or Anritsu, then duplicate this Emitter packets into FXTH87xx to form 315MHz, 433.92MHz TPMS emitter and receiver solution. Customer who adapts FXTH87xx can easily connect it with any external receiver using the similiar concept.
View full article
Hi Everyone, In this document I would like to present a simple example code I created for the FRDMKL25-P3115 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 both the pressure/altitude and temperature data that are read from the MPL3115A2 using an interrupt technique through the I 2 C interface. This example illustrates: 1. Initialization of the MKL25Z128 MCU (mainly PORT and I 2 C modules). 2. I 2 C 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/meters and °C 6. Visualization of the calculated values in the FreeMASTER tool. 1. As you can see in the FRDMSTBC-P3115 schematic and the image below, with jumpers J7 and J8 in their default position (2-3), the I 2 C signals are routed to the I2C1 module (PTC1 and PTC2 pins) of the KL25Z MCU. The INT1 output is connected to the PTA5 pin and configured as push-pull active-low output, so the corresponding PTA5 pin configuration is GPIO with an interrupt on falling edge. The configuration is done in the BOARD_InitPins() function. void BOARD_InitPins(void) {     CLOCK_EnableClock(kCLOCK_PortC);                                            /* Port C Clock Gate Control: Clock enabled */     CLOCK_EnableClock(kCLOCK_I2c1);                                             /* I2C1 Clock Gate Control: Clock enabled */     PORT_SetPinMux(PORTC, PIN1_IDX, kPORT_MuxAlt2);                             /* PORTC1 (pin 56) is configured as I2C1_SCL */     PORT_SetPinMux(PORTC, PIN2_IDX, kPORT_MuxAlt2);                             /* PORTC2 (pin 57) is configured as I2C1_SDA */     CLOCK_EnableClock(kCLOCK_PortA);                                            /* Port A Clock Gate Control: Clock enabled */     PORT_SetPinMux(PORTA, PIN5_IDX, kPORT_MuxAsGpio);                           /* PORTA5 (pin 31) is configured as PTA5 */     PORT_SetPinInterruptConfig(PORTA, PIN5_IDX, kPORT_InterruptFallingEdge);    /* PTA5 is configured for falling edge interrupts */     NVIC_EnableIRQ(PORTA_IRQn);                                                 /* Enable PORTA interrupt on NVIC */ } 2. The 7-bit I 2 C address of the MPL3115A2 is a fixed value 0x60 (defined in the MPL3115A2.h file) which translates to 0xC0 for a write and 0xC1 for a read. As mentioned before, the SCL line is connected to the PTC1 pin and SDA line to the PTC2 pin. The I 2 C clock frequency is 100 kHz. The I2C_Init() function is used to enable and configure the I2C1 module. void I2C_Init(void) {     i2c_master_config_t config = {     .enableMaster = true,     .enableStopHold = false,     .enableHighDrive = false,     .baudRate_Bps = 100000,     .glitchFilterWidth = 0      };     I2C_MasterInit(I2C1, &config, 24000000U);     I2C_MasterTransferCreateHandle(I2C1, &p_handle, i2c_master_callback, NULL); } The screenshot below shows the write operation which writes the value 0x39 to the CTRL_REG1 register (0x26). Here is a burst read of 5 bytes from registers 0x01 to 0x05. 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(I2C1, MPL3115A2_I2C_ADDRESS, CTRL_REG1, 0x04);               /* Reset all registers to POR values */     Pause(0xC62);          // ~1ms delay     I2C_WriteRegister(I2C1, MPL3115A2_I2C_ADDRESS, PT_DATA_CFG_REG, 0x07);         /* Enable data flags */     I2C_WriteRegister(I2C1, MPL3115A2_I2C_ADDRESS, CTRL_REG3, 0x00);               /* Push-pull, active low interrupt */     I2C_WriteRegister(I2C1, MPL3115A2_I2C_ADDRESS, CTRL_REG4, 0x80);               /* Enable DRDY interrupt */     I2C_WriteRegister(I2C1, MPL3115A2_I2C_ADDRESS, CTRL_REG5, 0x80);               /* DRDY interrupt routed to INT1 - PTA13 */     I2C_WriteRegister(I2C1, MPL3115A2_I2C_ADDRESS, CTRL_REG1, 0x39);               /* Active barometer mode, OSR = 128 */     //I2C_WriteRegister(I2C1, 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(void) {     PORT_ClearPinsInterruptFlags(PORTA, 1<<5);                /* 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(I2C1, MPL3115A2_I2C_ADDRESS, OUT_P_MSB_REG, RawData, 5);                      /* 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 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) (((RawData[0] << 16) | (RawData[1] << 8) | (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 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) ((short)((RawData[3] << 8) | (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 OUT_P_MSB and OUT_P_CSB.     The fraction component is located in bits 7-4 of OUT_P_LSB. Bits 3-0 of OUT_P_LSB are not used */     //Altitude = (float) ((short) ((RawData[0] << 8) | RawData[1])) + (float) (RawData[2] >> 4) * 0.0625; } 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
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
As requested in a prior posting...
View full article
Hello community, As we know, The MMA8451Q has embedded single/double and directional tap detection. This post describes an example project using the Single Tap detection for the MMA8451Q included on the FRDM-KL25Z. Figure 1. Depending on the tapping direction, positive or negative of each axis, the RGB LED will turn into a different color. For more detailed information on how to configure the device for tap detection please refer to NXP application note, AN4072. Configuring the MCU Enable the I2C module of the KL25Z MCU and turn on all the corresponding clocks. In this case, the INT1 output of the MMA8451Q is connected to the PTA14 pin and both SCL and SDA lines are connected to the I2C0 module (PTE24 and PTE25 pins). Please review the FRDM-KL25Z schematic.      //I2C0 module initialization        SIM_SCGC4 |= SIM_SCGC4_I2C0_MASK;        // Turn on clock to I2C0 module        SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK;       // Turn on clock to Port E module        PORTE_PCR24 = PORT_PCR_MUX(5);           // PTE24 pin is I2C0 SCL line        PORTE_PCR25 = PORT_PCR_MUX(5);           // PTE25 pin is I2C0 SDA line        I2C0_F = 0x14;                           // SDA hold time = 2.125us, SCL start hold time = 4.25us, SCL stop hold time = 5.125us *        I2C0_C1 = I2C_C1_IICEN_MASK;             // Enable I2C0 module                   //Configure the PTA14 pin (connected to the INT1 of the MMA8451Q) for falling edge interrupts        SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;       // Turn on clock to Port A module        PORTA_PCR14 |= (0|PORT_PCR_ISF_MASK|     // Clear the interrupt flag        PORT_PCR_MUX(0x1)|           // PTA14 is configured as GPIO        PORT_PCR_IRQC(0xA));         // PTA14 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); Configure the RBG LED of the FRDM-KL25Z Based on FRDM-KL25Z User's Manual , the RGB LED signals are connected as follow: The pins mentioned, are configured as output.      //Configure PTB18, PTB19 and PTD1 as output for the RGB LED        SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;    // Turn on clock to Port B module        SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;    // Turn on clock to Port D module                   PORTB_PCR18 |= PORT_PCR_MUX(0x1);     // PTB18 is configured as GPIO        PORTB_PCR19 |= PORT_PCR_MUX(0x1);     // PTB19 is configured as GPIO        PORTD_PCR1 |= PORT_PCR_MUX(0x1);      // PTD1 is configured as GPIO                   GPIOB_PDDR |= (1 << 18);              //Port Data Direction Register (GPIOx_PDDR)        GPIOB_PDDR |= (1 << 19);              //Set GPIO direction set bit corresponding bit on the direction        GPIOD_PDDR |= (1 << 1);               //register for each port, set the bit means OUTPUT Initialize and configure the MMA8451Q for Tap Detection To utilize the single and/or double tap detection the following eight (8) registers must be configured. Register 0x21: PULSE_CFG Pulse Configuration Register Register 0x22: PULSE_SRC Pulse Source Register Register 0x23 - 0x25: PULSE_THSX,Y,Z Pulse Threshold for X, Y and Z Registers Register 0x26: PULSE_TMLT Pulse Time Window 1 Register Register 0x27: PULSE_LTCY Pulse Latency Timer Register Register 0x28: PULSE_WIND Second Pulse Time Window Register Please review the MMA8451Q datasheet in order to get more information about the registers mentioned. For a single tap event, the PULSE_TMLT, PULSE_THSX/Y/Z and PULSE_LTCY registers are key parameters to consider. Note in condition (a) the interrupt is asserted since the acceleration due to a pulse exceeds the specified acceleration threshold (value set in the PULSE_THSX) and crosses up and down before the specified Pulse Time Limit (value set in PULSE_TMLT) expires. Note that in condition (b) the acceleration due to a pulse exceeds the specified acceleration threshold limit, but does not go below the threshold before the specified Pulse Time Limit expires. Therefore, this is an invalid pulse and the interrupt will not be triggered. Also note that the Latency is not shown for this example.              unsigned char reg_val = 0, CTRL_REG1_val = 0;            I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG2, 0x40);             // Reset all registers to POR values                 do            // Wait for the RST bit to clear        {               reg_val = I2C_ReadRegister(MMA845x_I2C_ADDRESS, CTRL_REG2) & 0x40;        }      while (reg_val);            I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG1, 0x0C);             // ODR = 400Hz, Reduced noise, Standby mode        I2C_WriteRegister(MMA845x_I2C_ADDRESS, XYZ_DATA_CFG_REG, 0x00);      // +/-2g range -> 1g = 16384/4 = 4096 counts        I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG2, 0x02);             // High Resolution mode            I2C_WriteRegister(MMA845x_I2C_ADDRESS, PULSE_CFG_REG, 0x15);         //Enable X, Y and Z Single Pulse        I2C_WriteRegister(MMA845x_I2C_ADDRESS, PULSE_THSX_REG, 0x20);        //Set X Threshold to 2.016g        I2C_WriteRegister(MMA845x_I2C_ADDRESS, PULSE_THSY_REG, 0x20);        //Set Y Threshold to 2.016g        I2C_WriteRegister(MMA845x_I2C_ADDRESS, PULSE_THSZ_REG, 0x2A);        //Set Z Threshold to 2.646g        I2C_WriteRegister(MMA845x_I2C_ADDRESS, PULSE_TMLT_REG, 0x28);        //Set Time Limit for Tap Detection to 25 ms        I2C_WriteRegister(MMA845x_I2C_ADDRESS, PULSE_LTCY_REG, 0x28);        //Set Latency Time to 50 ms        I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG4, 0x08);             //Pulse detection interrupt enabled        I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG5, 0x08);             //Route INT1 to system interrupt            CTRL_REG1_val = I2C_ReadRegister(MMA845x_I2C_ADDRESS, CTRL_REG1);   //Active Mode        CTRL_REG1_val |= 0x01;        I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG1, CTRL_REG1_val); Handle the Interrupt The PULSE_SRC register indicates a double or single pulse event has occurred and also which direction. In this case the value of the register mentioned is passed to the PULSE_SRC_val variable and evaluated. Reading the PULSE_SRC register clears all bits. Reading the source register will clear the interrupt.      void PORTA_IRQHandler()      {             PORTA_PCR14 |= PORT_PCR_ISF_MASK;               // Clear the interrupt flag              PULSE_SRC_val = I2C_ReadRegister(MMA845x_I2C_ADDRESS, PULSE_SRC_REG); //Read Pulse Source Register      } Please find attached the complete source code written in the CodeWarrior for Microcontrollers-Eclipse IDE|NXP . As I mentioned before, you can find more detailed information at application note AN4072. Useful information about handling the MMA8451 can be founded in MMA8451Q - Bare metal example project. I hope you find useful and funny this sample project. Regards, David
View full article
This is the 9 December 2014 build of Vibration Monitoring program written by Mark Pedley in the Sensors Solutions Division systems/algorithms team.  It is compatible with Freescale FRDM-KL25Z/KL26Z/KL46Z/K64F Freedom development platforms.  You can flash your board using the File->Flash pull-down menu.    The application contains an option for controlling motor bias and feedback via optional motor control shield to be discussed in an upcoming Freescale blog.  Use the View->Motor Controls pull-down to enable those functions.
View full article
For those of you who do not have access to Google Play, here is the latest .apk file for the Android version of the Sensor Fusion Toolbox.  This version should trap problems which caused previously reported crashes.  There are no visible changes to the functionality.   IF you have access to Google Play, we recommend that you use that as your default installer, as you can automatically get updates.
View full article
Hi Everyone,   If you are interested in a simple bare metal example code illustrating the use of the magnetic threshold detection function, please find below one of my examples I created for the FXOS8700CQ while working with the NXP FRDM-KL25Z platform and FRDM-FXS-MULT2-B sensor expansion board.   The FXOS8700CQ is set to detect magnetic field exceeding 12.8uT (128 counts) for a minimum period of 100ms on the X-axis. Once an event is triggered, an active low interrupt will be generated on the INT1 pin:   void FXOS8700CQ_Init (void) { I2C_WriteRegister(FXOS8700CQ_I2C_ADDRESS, M_THS_X_MSB_REG, 0x00); // Threshold value MSB I2C_WriteRegister(FXOS8700CQ_I2C_ADDRESS, M_THS_X_LSB_REG, 0x80); // Threshold value LSB I2C_WriteRegister(FXOS8700CQ_I2C_ADDRESS, M_THS_CFG_REG, 0xCB); // Event flag latch enabled, logic OR of enabled axes, only X-axis enabled, threshold interrupt enabled and routed to INT1 I2C_WriteRegister(FXOS8700CQ_I2C_ADDRESS, M_THS_COUNT_REG, 0x0A); // 100ms at 100Hz ODR and magnetometer mode only I2C_WriteRegister(FXOS8700CQ_I2C_ADDRESS, M_CTRL_REG1, 0x1D); // Max OSR, only magnetometer is active I2C_WriteRegister(FXOS8700CQ_I2C_ADDRESS, CTRL_REG3, 0x00); // Push-pull, active low interrupt I2C_WriteRegister(FXOS8700CQ_I2C_ADDRESS, CTRL_REG1, 0x19); // ODR = 100Hz, Active mode }‍‍‍‍‍‍‍‍‍‍     In the ISR, only the interrupt flag is cleared and the M_THS_SRC (0x53) register is read in order to clear the SRC_M_THS flag in the M_INT_SRC register and deassert the INT1 pin, as shown on the screenshot below.   void PORTD_IRQHandler() { PORTD_PCR4 |= PORT_PCR_ISF_MASK; // Clear the interrupt flag M_Ths_src=I2C_ReadRegister(FXOS8700CQ_I2C_ADDRESS, M_THS_SRC_REG); // Read the M_THS_SRC register to clear the SRC_M_THS flag in the M_INT_SRC register and deassert the INT1 pin Event_Counter++; }‍‍‍‍‍‍       Attached you can find the complete source code. If there are any questions regarding this simple example code, please feel free to ask below.    Regards, Tomas
View full article
Hi Everyone,   As I am often asked for a simple bare metal example code illustrating the use of the accelerometer transient detection function, I have decided to share here one of my examples I created for the FXLS8471Q accelerometer while working with the NXP FRDM-KL25Z platform and FRDM-FXS-MULT2-B sensor expansion board.   This example code complements the Python code snippet from the AN4693. The FXLS8471Q is set for detection of an “instantaneous” acceleration change exceeding 315mg for a minimum period of 40 ms on either the X or Y axes. Once an event is triggered, an interrupt will be generated on the INT1 pin:   void FXLS8471Q_Init (void) { FXLS8471Q_WriteRegister(TRANSIENT_THS_REG, 0x85); // Set threshold to 312.5mg (5 x 62.5mg ) FXLS8471Q_WriteRegister(TRANSIENT_COUNT_REG, 0x02); // Set debounce timer period to 40ms FXLS8471Q_WriteRegister(TRANSIENT_CFG_REG, 0x16); // Enable transient detection for X and Y axis, latch enabled FXLS8471Q_WriteRegister(CTRL_REG4, 0x20); // Acceleration transient interrupt enabled FXLS8471Q_WriteRegister(CTRL_REG5, 0x20); // Route acceleration transient interrupt to INT1 - PTA5 FXLS8471Q_WriteRegister(CTRL_REG1, 0x29); // ODR = 12.5Hz, Active mode } ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍     In the ISR, only the interrupt flag is cleared and the TRANSIENT_SRC (0x1E) register is read in order to clear the SRC_TRANS status bit and deassert the INT1 pin, as shown on the screenshot below.   void PORTA_IRQHandler() { PORTA_PCR5 |= PORT_PCR_ISF_MASK; // Clear the interrupt flag IntSource = FXLS8471Q_ReadRegister(TRANSIENT_SRC_REG); // Read the TRANSIENT_SRC register to clear the SRC_TRANS flag in the INT_SOURCE register EventCounter++; } ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍       Attached you can find the complete source code. If there are any questions regarding this simple example code, please feel free to ask below. Your feedback or suggestions are also welcome.   Regards, Tomas
View full article
The following video shows how to run the FRDM 6DOF Bare Board eCompass using the FRDM-K22. This algorithm uses the FXOS8700 contained on the Freedom Board. In order to get more information about the Sensor Fusion Library for Kinetis MCU's 5.0, please refer to the following link: Sensor Fusion|Freescale I hope this material will be useful for you. David
View full article
Unibody Package with Side Port_867B-04  
View full article
     The MC12311 is a highly-integrated, cost-effective, system-in-package (SIP), sub-1GHz wireless node solution with an FSK, GFSK, MSK, or OOK modulation-capable transceiver and low-power HCS08 8-bit microcontroller. The highly integrated RF transceiver operates over a wide frequency range including 315 MHz, 433 MHz, 470 MHz, 868 MHz, 915 MHz, 928 MHz, and 955 MHz in the license-free Industrial, Scientific and Medical (ISM) frequency bands.      The MPXY8600 is a sensor for use in applications that monitor tire pressure and temperature. It contains the pressure and temperature sensors, an X-axis and a Z-axis accelerometer, a microcontroller, an LF receiver and an RF transmitter all within a single package.      This document offer customers to utilize Freescale MPXY8600 as transmitter and MC12311 as receiver to form 315MHz, 433.92MHz TPMS transmitter and receiver solution.
View full article
The Freescale Freedom KL26Z hardware (FRDM-KL26Z) is a capable and cost-effective design featuring a Kinetis L series microcontroller, the industry’s first microcontroller built on the ARM® Cortex™-M0+ core. It features a KL26Z128VLH4 (KL26Z), a device boasting a maximum operating frequency of 48MHz, 128KB of flash. The FRDM-KL26Z features the Freescale open standard embedded serial and debug adapter known as OpenSDA. You can find more information at following link: FRDM-KL26Z: Freescale Freedom Development Platform for Kinetis KL16 and KL26 MCUs (up to 128 KB Flash) The second required board for this example is the Freescale's Freedom Development Platform for Multiple Xtrinsic Sensors, the FRDM-FXS-MULTI. It is a sensor expansion board that contains 7 sensors among which is the FXAS21000 Xtrinsic 3-axis gyroscopic sensors. This example is using above mentioned tools to create data acquisition system (DAQ) for acquiring angular rate data measured in deg/s from the FXAS21000 Xtrinsic 3-axis gyroscopic sensors (Gyro). For data logging and visualization of acquired data FreeMASTER tool is used. The output is in 3 directions of rotation. Around X direction is for the Roll (around longitudinal axis), around Y direction is for the Pitch (around the lateral axis) and around Z direction for the Yaw (around the vertical axis). The Gyro embedded registers are accessed through an I 2 C serial interface and routed to KL26Z I 2 C 1 module with following pin association. Precisely the 7-bit I 2 C slave address is 0x20 (SA0=0) and SCL1, SDA1 lines are routed to port C of the I 2 C 1 module at KL26Z board pins PTC1 and PTC2: Proper interrupt INT1_GYRO at J1-6 needs to be routed via jumper on J6 to INT_GYRO as shown in following block diagram since the interrupts are shared with other sensors: This is then handled as GPIO port A: PTA at the KL26Z board and configured for the falling edge interrupts. For more details see the schematics of the FRDM-FXS-MULTI block diagram. This example illustrates:    1.  Initialization of the KL26Z MCU (I 2 C and PORT modules).    2. Initialization of the Gyro to achieve the resolution 0.025 dsp/LSB with +/-200 dps range and a high-pass filter on.    3. Output data reading using an interrupt technique.    4. Conversion of the output values from registers 0x01 – 0x06 to real values in deg/s.    5. Visualization of the output values in the FreeMASTER tool. 1. According to the schematic, the INT1_GYRO output of the FXAS21000 is connected to the PTA5 pin of the KL26Z MCU and both SCL and SDA lines are connected to the I2C1 module (PTC1 and PTC2 pins). The MCU is, therefore, configured as follows:      void MCU_Init(void){              //I2C1 module initialisation         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(2);           // PTC1 pin is I2C1 SCL1 line pin alternative         PORTC_PCR2 = PORT_PCR_MUX(2);           // PTC2 pin is I2C1 SDA1 line pin alternative         I2C1_F = 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 PTA5 pin (connected to the INT_GYRO of the FXAS21000) 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. At the beginning of the initialization, all Gyro registers are reset to their default values by setting the RST bit of the CTRL_REG1 register. Also the ZR_cond in CTRL_REG1 to trigger the offset compensation is enabled and hold till ZR_cond offset compensation is accomplished. This is meant to be used only when the IC is in zero rate condition on all axes. Writing a '1' to this bit initiates the internal zero-rate offset calibration. The ZR_cond bit self-clears after the zero-rate offset calculation, and it can only be used once after a hard or soft reset has occurred. The measuring range of Gyro is set to ±200 dps and to achieve the highest resolution the ODR = 1.5625Hz (640ms) and the High-pass filter is enabled with H-P filter cutoff frq.:0.047 Hz.      void Gyro_Init (void){              unsigned char reg_val = 0;          I2C_WriteRegister(FXAS21_I2C_ADDRESS, CTRL_REG1, 0x40); // Reset all registers to POR values              do              // Wait for the RST bit to clear              {                 reg_val = I2C_ReadRegister(FXAS21_I2C_ADDRESS, CTRL_REG1) & 0x40;              } while (reg_val);         // Zero values initialisation ------------------------------------------------------------             //      I2C_WriteRegister(FXAS21_I2C_ADDRESS, CTRL_REG1, 0x80); // ZR_cond to trigger offset compensation             do      // wait till ZR_cond to trigger offset compensation accomplished          {           reg_val = I2C_ReadRegister(FXAS21_I2C_ADDRESS, CTRL_REG1) & 0x80;               } while (reg_val);             //----------------------------------------------------------------------------------------         I2C_WriteRegister(FXAS21_I2C_ADDRESS, CTRL_REG2, 0x0C); // Enable DRDY interrupt, DRDY interrupt routed to INT1 - PTA5, Push-pull, active low interrupt         I2C_WriteRegister(FXAS21_I2C_ADDRESS, CTRL_REG0, 0x17); // High-pass filter enabled, H-P filter cutoff frq.:0.047 Hz, +/-200 dps range -> 0.025 dsp/LSB = 40 LSB/dps         I2C_WriteRegister(FXAS21_I2C_ADDRESS, CTRL_REG1, 0x1E); // ODR = 1.5625Hz(640ms), Active mode      }      Below are the snap shots of write and read section of the registers from the instructions above.           3. 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;       }      4. The output values from Gyro registers 0x01 – 0x06 are first converted to signed 14-bit values and afterwards to real values in deg/s.      while(1){              if (DataReady){                 // Is a new set of data ready?                               DataReady = 0;                                                                                                I2C_ReadMultiRegisters(FXAS21_I2C_ADDRESS, OUT_X_MSB_REG, 6, GyrData);  // Read data output registers 0x01-0x06              Xout_14_bit = ((short) (GyrData[0]<<8 | GyrData[1])) >> 2;// Compute 14-bit X-axis output value      Yout_14_bit = ((short) (GyrData[2]<<8 | GyrData[3])) >> 2;// Compute 14-bit Y-axis output value              Zout_14_bit = ((short) (GyrData[4]<<8 | GyrData[5])) >> 2;// Compute 14-bit Z-axis output value                                        Roll = ((float) (Xout_14_bit)) / SENGYR_025D;   // Compute X-axis output value in dps              Pitch = ((float) (Yout_14_bit)) / SENGYR_025D;  // Compute Y-axis output value in dps              Yaw = ((float) (Zout_14_bit)) / SENGYR_025D;    // Compute Z-axis output value in dps                                    Temperature on the Gyro is also read out from the TEMP register of the Gyro              Temp = (signed char) I2C_ReadRegister(FXAS21_I2C_ADDRESS, TEMP_REG);  // temperature on Gyro      5. The calculated values can be watched in the "(x)= Variables" window on the top right of the Debug perspective of the CodeWarrior IDE or in the FreeMASTER application.      To open and run the FreeMASTER project, install the FreeMASTER 1.4 application and FreeMASTER Communication Driver that can be downloaded from following link:      FREEMASTER: FreeMASTER Run-Time Debugging Tool      User Guide for FreeMASTER is available within the installation.      For board communication in FreeMASTER following Options of Plug-in Module needs to be selected and configured for the BDM P&E Kinetis cable settings:             FreeMASTER in action screenshot: Enjoy the Freescale Gyro.
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
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
All, We are busily working to integrate Version 7.00 of the sensor fusion library into the Kinetis Expert (KEX) ecosystem.  ETA is early August.  I have attached here a preview copy of the user manual for that release.  This is subject to the usual disclaimers: content subject to change, no liability, yada yada yada.  There are a LOT of changes.    These are documented ad nauseum in the user guide.  I've also added a lot of our old blog content into the user guide, as I keep getting requests for them.  Please take a look and give me your feedback.   FYI, Here is a sample main() for the new fusion, running on FreeRTOS:   /* FreeRTOS kernel includes. */ #include "FreeRTOS.h" #include "task.h" #include "queue.h" #include "timers.h" #include "event_groups.h" // KSDK and ISSDK Headers #include "fsl_debug_console.h"  // KSDK header file for the debug interface #include "board.h"              // KSDK header file to define board configuration #include "pin_mux.h"            // KSDK header file for pin mux initialization functions #include "clock_config.h"       // KSDK header file for clock configuration #include "fsl_port.h"           // KSDK header file for Port I/O control #include "fsl_i2c.h"            // KSDK header file for I2C interfaces #include "Driver_I2C_SDK2.h"    // ISSDK header file for CMSIS I2C Driver #include "fxas21002.h"          // register address and bit field definitions #include "mpl3115.h"            // register address and bit field definitions #include "fxos8700.h"           // register address and bit field definitions // Sensor Fusion Headers #include "sensor_fusion.h"      // top level magCal and sensor fusion interfaces #include "control.h"           // Command/Streaming interface - application specific #include "status.h"            // Sta:tus indicator interface - application specific #include "drivers.h"           // NXP sensor drivers OR customer-supplied drivers // Global data structures SensorFusionGlobals sfg;                ///< This is the primary sensor fusion data structure ControlSubsystem controlSubsystem;      ///< used for serial communications StatusSubsystem statusSubsystem;        ///< provides visual (usually LED) status indicator PhysicalSensor sensors[3];              ///< This implementation uses three physical sensors EventGroupHandle_t event_group = NULL; static void read_task(void *pvParameters);              // FreeRTOS Task definition static void fusion_task(void *pvParameters);            // FreeRTOS Task definition /// This is a FreeRTOS (dual task) implementation of the NXP sensor fusion demo build. int main(void) {     ARM_DRIVER_I2C* I2Cdrv = &I2C_S_DRIVER_BLOCKING;       // defined in the <shield>.h file     BOARD_InitPins();                   // defined in pin_mux.c, initializes pkg pins     BOARD_BootClockRUN();               // defined in clock_config.c, initializes clocks     BOARD_InitDebugConsole();           // defined in board.c, initializes the OpenSDA port     I2Cdrv->Initialize(NULL);                                 // Initialize the KSDK driver for the I2C port     I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);      // Configure the I2C bus speed     initializeControlPort(&controlSubsystem);                           // configure pins and ports for the control sub-system     initializeStatusSubsystem(&statusSubsystem);                        // configure pins and ports for the status sub-system     initSensorFusionGlobals(&sfg, &statusSubsystem, &controlSubsystem); // Initialize sensor fusion structures     // "install" the sensors we will be using     sfg.installSensor(&sfg, &sensors[0], FXOS8700_I2C_ADDR, 1, (void*) I2Cdrv, FXOS8700_Init,  FXOS8700_Read);     sfg.installSensor(&sfg, &sensors[1], FXAS21002_I2C_ADDR, 1, (void*) I2Cdrv, FXAS21002_Init, FXAS21002_Read);     sfg.installSensor(&sfg, &sensors[2], MPL3115_I2C_ADDR, 2, (void*) I2Cdrv, MPL3115_Init, MPL3115_Read);     sfg.initializeFusionEngine(&sfg);         // This will initialize sensors and magnetic calibration     event_group = xEventGroupCreate();     xTaskCreate(read_task, "READ", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);     xTaskCreate(fusion_task, "FUSION", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);     sfg.setStatus(&sfg, NORMAL);                // If we got this far, let's set status state to NORMAL     vTaskStartScheduler();                      // Start the RTOS scheduler     sfg.setStatus(&sfg, HARD_FAULT);            // If we got this far, FreeRTOS does not have enough memory allocated     for (;;) ; } static void read_task(void *pvParameters) {     uint16_t i=0;                       // general counter variable     portTickType lastWakeTime;     const portTickType frequency = 1;   // tick counter runs at the read rate     lastWakeTime = xTaskGetTickCount();     while (1)     {         for (i=1; i<=OVERSAMPLE_RATE; i++) {             vTaskDelayUntil(&lastWakeTime, frequency);             sfg.readSensors(&sfg, i);              // Reads sensors, applies HAL and does averaging (if applicable)         }         xEventGroupSetBits(event_group, B0);     } } static void fusion_task(void *pvParameters) {     uint16_t i=0;  // general counter variable     while (1)     {         xEventGroupWaitBits(event_group,    /* The event group handle. */                             B0,             /* The bit pattern the event group is waiting for. */                             pdTRUE,         /* BIT_0 and BIT_4 will be cleared automatically. */                             pdFALSE,        /* Don't wait for both bits, either bit unblock task. */                             portMAX_DELAY); /* Block indefinitely to wait for the condition to be met. */         sfg.conditionSensorReadings(&sfg);  // magCal is run as part of this         sfg.runFusion(&sfg);                // Run the actual fusion algorithms         sfg.applyPerturbation(&sfg);        // apply debug perturbation (testing only)         sfg.loopcounter++;                  // The loop counter is used to "serialize" mag cal operations         i=i+1;         if (i>=4) {                         // Some status codes include a "blink" feature.  This loop                 i=0;                        // should cycle at least four times for that to operate correctly.                 sfg.updateStatus(&sfg);     // This is where pending status updates are made visible         }         sfg.queueStatus(&sfg, NORMAL);      // assume NORMAL status for next pass through the loop         sfg.pControlSubsystem->stream(&sfg, sUARTOutputBuffer);      // Send stream data to the Sensor Fusion Toolbox     } } /// \endcode
View full article
This is a pre-release .msi installer for the Freescale Sensor Fusion Toolbox for Windows NEXT RELEASE.  This (or a later copy) will eventually replace the release copy at http://www.freescale.com/sensorfusion.  Altough this is a preview copy, it is believed stable.  Please let us know of any issues seen.  This version has a nice feature in that it can re-flash your Freedom board (KL25Z, KL26Z, KL46Z, K20D50M and K64F) with the matching firmware.  The new feature is under the File->Flash menu item.  There have also been some nice changes made to the "Magnetics" view.
View full article
Hi Everyone,   I would like to share here one of my examples I created for the FXLS8471Q accelerometer while working with the Freescale FRDM-KL25Z platform and FRDM-FXS-MULT2-B sensor expansion board. It illustrates the use of the embedded FIFO buffer to collect the 14-bit acceleration data that are read from the FIFO using an interrupt technique through the SPI interface. For details on the configurations of the FIFO buffer as well as more specific examples and application benefits, please refer to the AN4073.   The FXLS8471Q is initialized as follows:   void FXLS8471Q_Init (void) {/* 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 */   FXLS8471Q_WriteRegister(CTRL_REG1, 0x00); // Standby mode FXLS8471Q_WriteRegister(F_SETUP_REG, 0xA0); // FIFO Fill mode, 32 samples   FXLS8471Q_WriteRegister(CTRL_REG4, 0x40); // Enable FIFO interrupt, push-pull, active low   FXLS8471Q_WriteRegister(CTRL_REG5, 0x40); // Route the FIFO interrupt to INT1 - PTA5   FXLS8471Q_WriteRegister(CTRL_REG1, 0x19); // ODR = 100Hz, Active mode }       In the ISR, only the interrupt flag is cleared and the FIFO_DataReady variable is set to indicate that the FIFO is full.   void PORTA_IRQHandler() { PORTA_PCR5 |= PORT_PCR_ISF_MASK; // Clear the interrupt flag FIFO_DataReady = 1; }       Once the FIFO_DataReady variable is set, the STATUS register (0x00) is read to clear the FIFO interrupt status bit and deassert the INT1 pin. Afterwars the FIFO is read using a 192-byte (3 x 2 x 32 bytes) burst read starting from the OUT_X_MSB register (0x01). Then the raw acceleration data are converted to signed 14-bit values and real values in g’s.   if (FIFO_DataReady) { FIFO_DataReady = 0; FIFO_Status = FXLS8471Q_ReadRegister(STATUS_REG); // Read the Status register to clear the FIFO interrupt status bit FXLS8471Q_ReadMultiRegisters(OUT_X_MSB_REG, 6*Watermark_Val, AccelData); // Read the FIFO using a burst read     for (i = 0; i < Watermark_Val; i++)   { // 14-bit accelerometer data   Xout_Accel_14_bit[i] = ((short) (AccelData[0 + i*6]<<8 | AccelData[1 + i*6])) >> 2; // Compute 14-bit X-axis acceleration output values   Yout_Accel_14_bit[i] = ((short) (AccelData[2 + i*6]<<8 | AccelData[3 + i*6])) >> 2; // Compute 14-bit Y-axis acceleration output values  Zout_Accel_14_bit[i] = ((short) (AccelData[4 + i*6]<<8 | AccelData[5 + i*6])) >> 2; // Compute 14-bit Z-axis acceleration output values   // Accelerometer data converted to g's   Xout_g[i] = ((float) Xout_Accel_14_bit[i]) / SENSITIVITY_2G; // Compute X-axis output values in g's  Yout_g[i] = ((float) Yout_Accel_14_bit[i]) / SENSITIVITY_2G; // Compute Y-axis output values in g's   Zout_g[i] = ((float) Zout_Accel_14_bit[i]) / SENSITIVITY_2G; // Compute Z-axis output values in g's   } }       Deassertion of the INT1 pin after reading the STATUS register (0x00).       ODR is set to 100Hz, so the FIFO is read every 320 ms (10 ms x 32 samples).       The calculated values can be watched in the "Variables" window on the top right of the Debug perspective.       Attached you can find the complete source code written in the CW for MCU's 10.6. If there are any questions regarding this simple example project, please feel free to ask below. Your feedback or suggestions are also welcome.   Regards, Tomas Original Attachment has been moved to: FRDM-KL25Z-FXLS8471Q-FIFO.rar
View full article
clicktaleID