Sensors Knowledge Base

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

Sensors Knowledge Base

Discussions

Sort by:
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
Hi Folks, Due to a very high number of questions from our customers regarding how to select the proper Freescale Pressure Sensor for their applications I have decided to create this illustrated, step-by-step easy to follow guideline about how to do it by yourself. Step 1: Go to http://www.freescale.com/webapp/parametricSelector.sp Then click on “Pressure Sensors” Now you should see the following window: And at this point everything is intuitive and basically the rest for select the proper Freescale Pressure Sensor depends on the requirements of your application. However, in order to trying to give you a better explanation, I’m doing an example: For this example let assume that my application requirements are as follow: Pressure measurement range up to 100kPa (higher priority parametric search for my app) Absolute Pressure Sensor Analog Output Integrated Side Ported Mount surface Package: SOP 8 (*I added the “Package Type” Parametric Search) (lower priority) *You can add or remove search parameters clicking on the “Show/Hide Parameters” button.  Based on the mentioned requirements, I selected the check boxes on the Parametric Search Window starting from the parametric with higher priority and leaving the parametric with lower priority at the end, and as a result I will get something like the image below: * You can leave unselected check boxes if are not important for your application, for my example from the image above I leave the “Ambient Operating Temperature” option unselected. So, from the initial 37 pressure sensors options I have to select, now the list it’s reduced to only 1 option, so, for this particular example, the MPXV5100 is the best solution for my application. If there are any questions regarding this guideline, please feel free to ask below. Your feedback or suggestions are also welcome. Regards, Jose
View full article
FXLS93xxx 是NXP针对底盘安全领域的PSI5接口的加速度传感器。FXPS7140xxxx 是NXP针对气囊中侧碰,行人保护等应用推出的PSI5接口的压力传感器。   FXLS93xxx内部集成了OTP, One-Time-Programmable Memory (一次性烧写,不支持客户重复烧写),这种OTP Memory 分为NXP工厂烧写部分(Type是F),客户可读,和客户可烧写部分(UF0, UF1 & UF2). 支持客户烧写的范围是UF0($E0-EE), UF1($F0-FF) & UF2($16-5E) 的区间。芯片内还有部分寄存器是客户可读的和 可读可写的寄存器(非OTP的,写的内容会随下电后重新上电后消失,可以理解为RAM)。 未经烧写OTP的芯片会工作在默认模式PSI5-P16C-500/2L,FXLS93xx0(单轴)加速度数据会在Time slot 1发送,FXLS93xxx(双轴)加速度数据,Ch0数据会在Time slot 1发送,Ch1数据会在Time slot 2发送。 OTP programming 烧写流程     进入烧程模式PME(Programming Mode Entry)的时序 上电后delay(tRS_PM) 6ms     发至少31个同步头,同步头的时间周期必须满足 245-255us   发PME command 注:上电后6ms+127ms中如果没有收到PME command, 则退出PM Entry.       烧写电压Vpp 电压9-11V是指BUS_I/VCC pin上电压   依据寄存器配置内容,写寄存器,寄存器默认值为0x00,如配置内容是默认值,则不需要写 寄存器配置内容写好后, 写0x80到WRITE_OTP_EN($11) 烧写UF0, delay 10ms 烧写完成 写0x81到WRITE_OTP_EN($11) 烧写UF1, delay 10ms 烧写完成 写0x8E(跳过COMMTYPE和PHYSADDR寄存器烧写)到WRITE_OTP_EN($11) 烧写UF2, delay 10ms 烧写完成   验证步骤: 读回烧写过的寄存器,确保烧写内容是否正确 读DEVSTAT和DEVSTAT2 寄存器,判断是否在烧写过程中有错误产生。 烧写UF1,UF2后,做Margin read, 判断烧写深度是否足够   烧写注意事项: OTP烧写中常出现的问题主要是烧写深度不足。失效现象是通过PSI5总线收到传感器错误代码,10-bit 500 即0x1F4, 16-bit 32000 即 0x7D00(PSI5_CFG寄存器中 EMSG_EXT = 0),10-bit 491 即0x1EB, 16-bit 31424 即 0x7AC0(PSI5_CFG寄存器中 EMSG_EXT = 1)错误码可能是会在传感器放置或者工作后一段时间,如几天,几个月或更长时间后产生,所以如发生该问题容易导致客户端失效。目前已知原因是: 烧写电压VPP不够: Datasheet中Vpp 电压9-11V是指BUS_I/VCC pin上电压,要考虑串联电阻和线束的压降,确保烧写OTP过程中,BUS_I pin电压稳定在这个范围内 烧写时间不足,写WRITE_OTP_EN后的延时必须大于10ms, 以保证烧写完成(这里写的OTP Program Timing 最大值10ms是每颗芯片需要烧写的时间有区别,但芯片最大的烧写时间是10ms, 所以烧写时间需要大于10ms以确保每颗芯片都烧写深度足够。)     为确保该问题不发生,请确保前面的两点已经满足,并且推荐烧写UF1,UF2后,做Margin read, 判断烧写深度是否足够。并将所有烧写后寄存器读回,判断烧写内容是否正确。 还要注意进入烧写模式(PME)后,请勿热插拔FXLS93xxx 芯片或模块, 以避免芯片损坏。   烧写工具: 很多客户除了做PSI5传感器, 还在做含有PSI5接口的ECU. 所以我们的文档可以支持客户自己开发PSI5 OTP烧写工具。(NXP 没有烧写工具的解决方案) 购买Seskion的 PSI5 Simulyzer进行烧写 Seskion PSI5-Simulyzer – Measuring, Analyzing, Simulating 下面是介绍如何通过Seskion PSI5 Simulyzer 进行快速烧写     Seskion configuration Once the script is generated from the NXP script generator tool you will need to load it on the PSI5 Simulyzer from Seskion by going into Tools-> ECU Pattern Editor -> Channel 0 -> Load -> Select generated script file. Make sure that “Use for Sensor Init” is ticked , see below snapshot.                 Below an example of a script generated by the Seskion Script generation tool :           The 2 first “0” are trimmed out by the defined number of bit set to 0x2A = 42. Note : Once the script file are loaded to the PSI5-Simulizer from Seskion the “00” from 00b32ba623e are not shown and what will be displayed is b32ba623e. However since the number of bit is 0x2A = 42 the 5x ‘0’ are automatically appended at the beginning of the command.         If the programming using the PSI5 Simulyzer from Seskion is not working there few things to consider for debug : Make Sure that the bit distance in bidirectional communication is set to 250us as specified in sensor product specification.     Make sure that Init Phase1 timing is set to 6.     If device respond to PSI5 programming command but the configuration is not getting written into OTP, please make sure that the applied voltage level is within product specification 9-11V at BUS_I pin. So please include potential voltage drop cause by any potential resistor connected on BUS_I/VCC pin.   烧写过程,一定是先点RUN, 然后再点Power ,烧写完成后sensor一直发送0x1e1, 就代表烧写成功了      
View full article
FXLS93xxx 是NXP针对底盘安全领域的PSI5接口的加速度传感器。FXPS71407BPS 是NXP针对气囊中侧碰,行人保护等应用推出的PSI5接口的压力传感器。 FXLS93xxxx/FXPS71407BPS 芯片出厂时,COMMTYPE中COMMTYPE[2:0]被设置成0x1. 除COMMTYPE中这一位,其它寄存器默认值都是0. 虽然都是QFN 4mm x 4mm 封装,但pin脚顺序不同,PCB不共用 下面仅介绍了在PSI5模式下最常配置的几个寄存器,其它的配置请参考对应的datasheet 芯片烧写OTP前,有默认模式(un-programmed PSI5)输出 PSI5-P16C-500/2L with 400 Hz, 4-Pole low-pass filter.   SOURCEID_0, SOURCEID_1, SOURCEID_2, SOURCEID_3的配置 SOURCEID_0, SOURCEID_1 对应CH0 SOURCEID_2, SOURCEID_3对应CH1 具体的CH0 和CH1对应的加速度传感器在datasheet 第一页中可以找到       注:PIS5异步模式(Async mode), 仅SOURCEID_0 有效   例: FXLS93220, 这是X单轴的,它仅能使用Channel 0, 所以配置中仅能配置SOURCEID_0 或 SOURCEID_1 。   FXLS93421, CH0对应的是X轴Middle-g, CH1对应的是Z-axis Low-g的加速度传感器。 如果要使用Z-axis Low-g的加速度传感器,则配置SOURCEID_2 或 SOURCEID_3,如果一个同步周期内只需发一组加速度值,则配SOURCEID_2 就可以了。     SOURCEID_0 中PDCMFORMAT[2:0],例:PSI5需要配置为P16CRC-1000/3H ,数据需要以16-bit 输出, 则配置PDCMFORMAT[2:0] =0b1xx   PSI5_CFG ($25) 最常需配置的位 P_CRC(默认是奇偶校验,写1是CRC校验),ASYNC(默认是Sync mode, 同步模式, 写1改为异步模式Async) EMSG_EXT 如果模块的spec里没有特别要求,建议写1,因为在模块失效时,可以提供更多的失效信息,便于做FA. PSI5_CFG 其它位的配置主要看系统的结构或接收端是否支持。 PDCM_RSPSTx($26-$2B) 在Sync mode下,PDCM_RSPST0,PDCM_RSPST1,PDCM_RSPST2,PDCM_RSPST3 对应于SOURCEID_0, SOURCEID_1,SOURCEID_2, SOURCEID_3 的数据开始发送的时间, Start time, 这里配置的是tTIMESLOTx的值, tA_SYNC_DLY只有50-600ns.   例: SOURCEID_2的数据开始发送的Timeslot start time是244 μs, 则配置PDCM_RSPST2_L = 0xF4 通过配置的SOURCEID_x选择对应的CHx_CFG_U1,CHx_CFG_U2,CHx_CFG_U3,CHx_CFG_U4,CHx_CFG_U5进行配置。 PDCM_CMD_B_L($38) PDCM_CMD_B_H($39) PSI5 Command Blocking Time 全0为默认值450us. CH0_CFG_U1($40), CH1_CFG_U1($48) 根据产品需求,在下表中选择合适的LPF[3:0]和SAMPLERATE[1:0]. 该滤波器更详细的内容见Low-pass filter 章节     CH0_CFG_U2($41), CH1_CFG_U2($49)  寄存器U_SNS_MULT[7:0]的配置需结合CHx_CFG_U1中USER_SNS_SHIFT[1:0]一起配置。通过这个配置,可以得到对应的sensitivity和g-range. 具体计算可以参考uGen6UserSensitivityMultiplierCaculation.xslx 文件。注:PSI5 10-bit数据输出范围是-480 ~ 480 LSB, PSI5 16-bit数据输出范围为-30720 ~ 30720 LSB. (这是PSI5协议规定的) CH0_CFG_U3($42), CH1_CFG_U3 ($4A) CHxDATATYPE0 和 CHxDATATYPE1 , 默认是使能Offset cancellation自动归零功能的。通过这个寄存器配置,可以关闭该功能。 MOVEAVG[1:0] 默认是使用的LPF, 通过MOVEAVG[1:0]配置,可以关闭LPF, 使能平均值滤波。 CH0_CFG_U4($43), CH1_CFG_U4($4B) INVERT 如发现数据输出的正负和期望值是相反的,则将该位置1 假设将传感器转90度,即Offset为1g,当OC_FILT[1:0] 为0时 则由于OC Rate Limiting 的速度是1LSB/4s for PSI5 10-bit(or 16LSB/s for PSI5 16-bit). 如果1g对应的输出是32个LSB (PSI5 10-bit),则需要32*0.25 = 128s实现1g的自动归零功能。 如果使用0.04Hz,OC_FILT[1:0]=1,关闭OC Rate Limiting功能,则 18.36sec 实现归零 final value (+/-1%) . (最快的) 如果使用0.005Hz,OC_FILT[1:0]=2,?   CH0_U_OFFSET_L($55), CH0_U_OFFSET_H($56), CH1_U_OFFSET_L($5D), CH1_U_OFFSET_H($5E) 当测量轴向在重力加速度方向,则需要配置该寄存器。配置的具体值参考uGen6UserSensitivityMultiplierCaculation.xslx 文件。例如FXLS93421, 当使用Z-axis在垂直方向时,由于重力加速度的耦合,使Offset超过了400mg,PSI5总线会报Offest Error信息(EMSG_EXT=1)或是Sensor Defect Error信息(EMSG_EXT=0). 以上仅是FXLS93xxxx/FXPS71407BPS最常做的配置,注意FXPS71407BPS和FXLS93xxxx的配置还是有很多区别的,如只支持10-bit PSI5 输出,所以请以对应的datasheet为准。
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
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
Freescale’s FXOS8700CQ 6-axis sensor combines industry leading accelerometer and magnetometer sensors in a small 3 x 3 x 1.2 mm QFN plastic package. The 14-bit accelerometer and 16-bit magnetometer are combined with a high-performance ASIC to enable an eCompass solution capable of a typical orientation resolution of 0.1 degrees and sub 5 degree compass heading accuracy for most applications. Applications include eCompass, enhanced user interface, augmented reality, and location based services (static geographic heading). Target products include smartphones, tablets, personal navigation devices, remote controls for smart TV’s, watches, gaming controllers, robotics, and unmanned air vehicles (UAVs). Here is a Render of the FXOS8700 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
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, As I am frequently asked for a simple bare metal example code for the Xtrinsic MMA8451Q digital accelerometer, I would like to share here one of my examples I have created for this part while working with the Freescale FRDM-KL25Z platform. This example illustrates: 1. Initialization of the MKL25Z128 MCU (mainly I2C and PORT modules). 2. Initialization of the accelerometer to achieve the highest resolution. 3. Simple offset calibration based on the AN4069. 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. According to the schematic, the INT1 output of the MMA8451Q is connected to the PTA14 pin of the KL25Z MCU and both SCL and SDA lines are connected to the I2C0 module (PTE24 and PTE25 pins). The MCU is, therefore, configured as follows: void MCU_Init(void) {      //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); } 2. At the beginning of the initialization, all accelerometer 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). void Accelerometer_Init (void) {      unsigned char reg_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, 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, CTRL_REG1, 0x3D);           // ODR = 1.56Hz, Reduced noise, Active mode   } 3. A simple offset calibration method is implemented according to the AN4069. At the end of the calibration routine, the DRDY interrupt is enabled and routed to the INT1 interrupt pin that is configured to be a push-pull, active-low output. void Calibrate (void) {      unsigned char reg_val = 0;            while (!reg_val)           // Wait for a first set of data               {         reg_val = I2C_ReadRegister(MMA845x_I2C_ADDRESS, STATUS_REG) & 0x08;      }               I2C_ReadMultiRegisters(MMA845x_I2C_ADDRESS, 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                                          I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG1, 0x00);             // Standby mode to allow writing to the offset registers       I2C_WriteRegister(MMA845x_I2C_ADDRESS, OFF_X_REG, Xoffset);              I2C_WriteRegister(MMA845x_I2C_ADDRESS, OFF_Y_REG, Yoffset);       I2C_WriteRegister(MMA845x_I2C_ADDRESS, OFF_Z_REG, Zoffset);       I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG3, 0x00);             // Push-pull, active low interrupt      I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG4, 0x01);             // Enable DRDY interrupt      I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG5, 0x01);             // DRDY interrupt routed to INT1 - PTA14      I2C_WriteRegister(MMA845x_I2C_ADDRESS, 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 PORTA_IRQHandler() {      PORTA_PCR14 |= PORT_PCR_ISF_MASK;            // Clear the interrupt flag      DataReady = 1;      } 5. 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;                                                                                                                      I2C_ReadMultiRegisters(MMA845x_I2C_ADDRESS, 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                                   } 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 view both the 14-bit and real values in the FreeMASTER application, some USBDM drivers need to be first installed on your computer. They are available for download from SourceForge. Erich Styger described their installation in this tutorial. In addition to that, the USBDM_OpenSDA application that provides both debugging and a virtual serial port needs to be loaded into the MK20 debugger chip on the FRDM-KL25Z board. This installation follows the usual FRDM-KL25Z bootloader process: Unplug the FRDM-KL25Z board. Whilst holding the SW1/RST switch depressed plug in the FRDM-KL25Z board. The green LED should start blinking at a rate of about 1Hz. Open a file explorer and locate the USB drive that has now appeared. It will have the drive name "BOOTLOADER". Drag the file USBDM_OpenSDA.sx to the USB drive and wait a short while. The OpenSDA firmware on the FRDM-KL25Z board will program the USBDM firmware into the MK20 debugger chip on the board. Remove and re-plug the FRDM-KL25Z board. The board will now appear as a USBDM device. Attached you can find the complete source code written in the CW for MCU's v10.5 as well as the FreeMASTER project. So make it, test it and keep in touch... Regards, Tomas
View full article
Hi Everyone,   I would like to share here another simple bare-metal example code/demo for the Xtrinsic MMA8652FC digital accelerometer that I have created while working with the Freescale FRDM-KL25Z development platform and FRDM-FXS-MULTI(-B) sensor expansion board. To visualize the acceleration data that are read from the MMA8652FC using an interrupt technique through the I 2 C interface, I have used the FreeMASTER tool.   This example illustrates:   1. Initialization of the MKL25Z128 MCU (mainly I 2 C and PORT modules). 2. I 2 C 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, I2C signals are routed to the I2C1 module (PTC1 and PTC2 pins) of the KL25Z MCU and the INT1 output is connected to the PTA5 pin (make sure that pin #3 of J4 and pin #2 of J6 connector on the sensor expansion board are connected together). The INT1 output of the MMA8652FC is configured as a push-pull active-low output, so the corresponding PTA5 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 PTA5 pin (connected to the INT1 of the MMA8652FC) 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 7-bit I 2 C address of the MMA8652FC is fixed value 0x1D. 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 (0x2A).     And here is the single byte read from the WHO_AM_I register 0x0D. As you can see, it returns the correct value 0x4A.     Multiple bytes of data can be read from sequential registers after each MMA8652FC 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 6 bytes from registers 0x01 to 0x06 is shown below. It also shows how the INT1 pin is automatically deasserted by reading the acceleration output data.       3. At the beginning of the initialization, all 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 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 MMA8652FC_Init (void) {      I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, CTRL_REG2, 0x40);          // Reset all registers to POR values           Pause(0x631);          // ~1ms delay           I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, XYZ_DATA_CFG_REG, 0x00);   // +/-2g range with ~0.977mg/LSB       I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, CTRL_REG2, 0x02);          // High Resolution mode      I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, CTRL_REG3, 0x00);          // Push-pull, active low interrupt      I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, CTRL_REG4, 0x01);          // Enable DRDY interrupt      I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, CTRL_REG5, 0x01);          // DRDY interrupt routed to INT1 - PTA5      I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, CTRL_REG1, 0x39);          // ODR = 1.56Hz, Active mode       }   4. A simple offset calibration method is implemented according to the AN4069.   void MMA8652FC_Calibration (void) {      char X_offset, Y_offset, Z_offset;           DataReady = 0;                while (!DataReady){}          // Is a first set of data ready?      DataReady = 0;           I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, CTRL_REG1, 0x00);          // Standby mode                I2C_ReadMultiRegisters(MMA8652FC_I2C_ADDRESS, OUT_X_MSB_REG, 6, AccelData);          // Read data output registers 0x01-0x06                         Xout_12_bit = ((short) (AccelData[0]<<8 | AccelData[1])) >> 4;             // Compute 12-bit X-axis acceleration output value      Yout_12_bit = ((short) (AccelData[2]<<8 | AccelData[3])) >> 4;             // Compute 12-bit Y-axis acceleration output value      Zout_12_bit = ((short) (AccelData[4]<<8 | AccelData[5])) >> 4;             // Compute 12-bit Z-axis acceleration output value                  X_offset = Xout_12_bit / 2 * (-1);          // Compute X-axis offset correction value      Y_offset = Yout_12_bit / 2 * (-1);          // Compute Y-axis offset correction value      Z_offset = (Zout_12_bit - SENSITIVITY_2G) / 2 * (-1);         // Compute Z-axis offset correction value                  I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, OFF_X_REG, X_offset);                  I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, OFF_Y_REG, Y_offset);            I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, OFF_Z_REG, Z_offset);                        I2C_WriteRegister(MMA8652FC_I2C_ADDRESS, CTRL_REG1, 0x39);          // 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 12-bit values and afterwards to real values in g’s.   if (DataReady)             // Is a new set of data ready? {                  DataReady = 0;                                                                                                                         I2C_ReadMultiRegisters(MMA8652FC_I2C_ADDRESS, OUT_X_MSB_REG, 6, AccelData);          // Read data output registers 0x01-0x06                    // 12-bit accelerometer data      Xout_12_bit = ((short) (AccelData[0]<<8 | AccelData[1])) >> 4;             // Compute 12-bit X-axis acceleration output value      Yout_12_bit = ((short) (AccelData[2]<<8 | AccelData[3])) >> 4;             // Compute 12-bit Y-axis acceleration output value      Zout_12_bit = ((short) (AccelData[4]<<8 | AccelData[5])) >> 4;             // Compute 12-bit Z-axis acceleration output value                             // Accelerometer data converted to g's      Xout_g = ((float) Xout_12_bit) / SENSITIVITY_2G;              // Compute X-axis output value in g's      Yout_g = ((float) Yout_12_bit) / SENSITIVITY_2G;              // Compute Y-axis output value in g's      Zout_g = ((float) Zout_12_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 application and FreeMASTER Communication Driver.       Attached you can find the complete source code written in the CW for MCU's (Eclipse IDE) 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
View full article
  LGA 8 PACKAGE 5.0 mm x 3.0 mm x 1.1 mm  
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
Attached is a PDF dump of a classic blog post.  Please forgive the format problems.  I'll work with the web team in January to get it reposted to the NXP site. Mike
View full article
Hi, The MPL3115A2, provides highly accurate pressure and altitude data with variable sampling rate capability. It has very low-power consumption, smart features and requires zero data processing, it is ideal for mobile devices, medical and security applications. Here is a Render of the MPL3115A2 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
clicktaleID