<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Re: Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317117#M14014</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wrote&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"..and the values printed out &lt;SPAN style="text-decoration: underline;"&gt;may be about&lt;/SPAN&gt; what are expected".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would print the values out as hexadecimal since as decimal it is difficult to see exactly what is happening - see my original example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since this detail is more general coding I'll leave it to you to sort out because the accelerometer seems to be doing its job and also the I2C operation looks realistic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to do some general improvements I would suggest reading the status register as well as just the result values since this will also show whether there were errors and that the conversion has completed, etc. It also means that the reads can be made without always first commanding the address to be read from since the accelerometer's internal, address pointer wraps around to the status register after the conversion results have been read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As reference I have shown the code to do this in the uTasker project below. It allows simulation of the KL02, I2C and the accelerometer so also makes it much easier to test and debug (using VisualStudio).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14049270692337171" jivemacro_uid="_14049270692337171" modifiedtitle="true"&gt;
&lt;P&gt;static const unsigned char ucReadAccelerometerState[] = {RESULT_LENGTH, MMA8451Q_READ_ADDRESS, OWN_TASK}; // command to start a read the defined amount of bytes with the task scheduled when the read has completed&lt;/P&gt;
&lt;P&gt;static const unsigned char ucSetAccelerometerRead[] = {MMA8451Q_WRITE_ADDRESS, 0}; // command to set address to read to the first register address (status)&lt;/P&gt;
&lt;P&gt;static const unsigned char ucSetAccelerometerMode[] = {MMA8451Q_WRITE_ADDRESS, ACC_CONTROL_REGISTER, (ACC_CONTROL_REGISTER_ACTIVE | ACC_CONTROL_REGISTER_DATA_RATE_50Hz | ACC_CONTROL_REGISTER_SLEEP_RATE_6_25Hz | ACC_CONTROL_REGISTER_LNOISE)}; // command to set the 14-bit resolution mode&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;#define RESULT_LENGTH 7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // 14 bit mode 1 status byte and 6 result bytes&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;// Initialisation&lt;/P&gt;
&lt;P&gt;//&lt;/P&gt;
&lt;P&gt;fnWrite(IICPortID, (unsigned char *)ucSetAccelerometerMode, sizeof(ucSetAccelerometerMode)); // write the operating mode&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;// Followed by the first status read&lt;/P&gt;
&lt;P&gt;//&lt;/P&gt;
&lt;P&gt;fnWrite(IICPortID, (unsigned char *)ucSetAccelerometerRead, sizeof(ucSetAccelerometerRead)); // write the register address to read&lt;/P&gt;
&lt;P&gt;fnRead(IICPortID, (unsigned char *)ucReadAccelerometerState, 0); // start the read process of the status&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;// I2C reception&lt;/P&gt;
&lt;P&gt;//&lt;/P&gt;
&lt;P&gt;if (fnRead(IICPortID, ucInputMessage, RESULT_LENGTH) != 0) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if the result read has completed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnSetColor((signed char)ucInputMessage[1], (signed char)ucInputMessage[3]); // set the colour to the LED&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnDebugMsg("3-axis state:");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // display the status on a regular basis&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (i &amp;lt; RESULT_LENGTH) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // display 4 values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (i == 0) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnDebugHex(ucInputMessage[i], (sizeof(ucInputMessage[i]) | WITH_LEADIN | WITH_SPACE)); // display the received register contents&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned short usValue = ucInputMessage[i++];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usValue &amp;lt;&amp;lt;= 8;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usValue |= ucInputMessage[i];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnDebugHex(usValue, (sizeof(usValue) | WITH_LEADIN | WITH_SPACE)); // display the received register contents&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i++;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnDebugMsg("\r\n");&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnRead(IICPortID, (unsigned char *)ucReadAccelerometerState, 0); // start the read process of the next value&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Jul 2014 17:34:21 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2014-07-09T17:34:21Z</dc:date>
    <item>
      <title>FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317097#M13994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have managed to get the 3 - axis accelerometer working, using an 8 bit measurement. I actually followed a guide online: &lt;A href="http://mcuoneclipse.com/2012/09/21/tutorial-accelerating-the-kl25z-freedom-board/"&gt;http://mcuoneclipse.com/2012/09/21/tutorial-accelerating-the-kl25z-freedom-board/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its been very helpful. I wish to now use a 14 bit measurement using the same setup. I'm however having difficulties. I have setup a terminal using Putty, to display my xyz values so far for the 8 bit measurement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been trying to edit the code myself, with the help of the data sheet for the accelerometer however the values I'm getting are incorrect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My understanding from the online guide for the 8 bit measurement is that &lt;SPAN style="color: #808080; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 15px;"&gt;#define MMA8451_OUT_X_MSB 0x01&lt;/SPAN&gt;, &lt;SPAN style="color: #808080; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 15px;"&gt;#define MMA8451_OUT_Y_MSB 0x03&lt;/SPAN&gt;,&lt;SPAN style="color: #808080; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 15px;"&gt;#define MMA8451_OUT_Z_MSB 0x05&lt;/SPAN&gt; are being used to get the correct 8 bit measurement.&lt;/P&gt;&lt;P&gt;However, to get the 14 bit measurement, I must use the LSB values as well. I will end up having a 16 bit number, so I have to concatenate or mask (not sure if my terminology is correct) the values to get a 14 bit measurement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I on the right track so far?&lt;/P&gt;&lt;P&gt;Any ideas how to get the 14 bit measurement to work??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jul 2014 21:12:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317097#M13994</guid>
      <dc:creator>markadamson</dc:creator>
      <dc:date>2014-07-07T21:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317098#M13995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In 8 bit mode the accelerometer is set up in &lt;STRONG&gt;F_MODE&lt;/STRONG&gt; and reading three values from address 0x01 returns the contents of the internal registers 0x01, 0x03, 0x05 which are the 8 MSBits of the conversion result (X_MSB, Y_LSB, Z_MSB).&lt;/P&gt;&lt;P&gt;To read in 14 bit mode the &lt;STRONG&gt;F_MODE&lt;/STRONG&gt; is &lt;SPAN style="text-decoration: underline;"&gt;not&lt;/SPAN&gt; set and then instead of reading 3 bytes from the address 0x01, 6 bytes need to be read which contain X_MSB, X_LSB, Y_MSB, Y_LSB, and Z_MSB, Z_LSB,&lt;/P&gt;&lt;P&gt;To convert the two bytes to a single 16 bit value (with 14 bits of resolution) do something like (assuming the 6 bytes from the accelerometer have been read to array[6])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;unsigned short usX = ((array[0] &amp;lt;&amp;lt; 8) | array[1]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;unsigned short usY = ((array[2] &amp;lt;&amp;lt; 8) | array[3]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;unsigned short usZ = ((array[4] &amp;lt;&amp;lt; 8) | array[5]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the uTasker project setting the define &lt;STRONG&gt;MMA8451Q_14BIT_RES&lt;/STRONG&gt; operates the I2c/accelerometer interface in 14 bit mode (16 bit result with 14 byte resolution) and without it operates in 8 bit mode (8 bit result with 8 bit resolution).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As reference I have attached two binaries for the FRDM-KL02Z built for 8 bit and 14 bit modes. In each case the RGB LED's colour is controlled by the tilt of the board and the accelerometer values can be seen on the UART (virtual COM connection at 115200 Baud) when enabled in the I2C menu (menu 7) with the command "acc_on" ["acc_off" disables]. For example in 14 bit mode:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[first byte is state, followed by X,Y,Z]&lt;/P&gt;&lt;P&gt;3-axis state: 0x00 0xfde4 0x0054 0x3f78&lt;/P&gt;&lt;P&gt;3-axis state: 0x00 0xfdd8 0x0048 0x3fa8&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and compared in 8 bit mode:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3-axis state: 0x00 0xfe 0xff 0x3f&lt;/P&gt;&lt;P&gt;3-axis state: 0x00 0xfe 0x00 0x3f&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that a power cycle seems to be necessary when changing the mode of operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jul 2014 23:19:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317098#M13995</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-07-07T23:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317099#M13996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;you might have a look at the project on &lt;A href="https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-KL25Z/Freedom_Accel" title="https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-KL25Z/Freedom_Accel"&gt;mcuoneclipse/Examples/FRDM-KL25Z/Freedom_Accel at master · ErichStyger/mcuoneclipse · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The project shows reading values in non-fast (F_MODE disabled), so you can get more than 8bit values.&lt;/P&gt;&lt;P&gt;Switching off fast mode is done with&lt;/P&gt;&lt;P&gt;&amp;nbsp; res = MMA1_SetFastMode(FALSE);&lt;/P&gt;&lt;P&gt;Then you can use for example MMA1_GetX() (or the Y or Z counterparts) to get all the bits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 08:31:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317099#M13996</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2014-07-08T08:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317100#M13997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ Erich, Your method seems easier to understand for me. However, it seems like I need a different Processor Expert component. I have gone to the github link, under the beans folder, however I don't see a download zip option like a normally do. Could you help me with this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, is there a way I can get the 14-bit data, without having to use a different processor expert component?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 10:25:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317100#M13997</guid>
      <dc:creator>markadamson</dc:creator>
      <dc:date>2014-07-08T10:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317101#M13998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;the components are as *.PEupd files in &lt;A href="https://github.com/ErichStyger/mcuoneclipse/tree/master/PEupd" title="https://github.com/ErichStyger/mcuoneclipse/tree/master/PEupd"&gt;mcuoneclipse/PEupd at master · ErichStyger/mcuoneclipse · GitHub&lt;/A&gt;, and you need to download and install both files (see &lt;A href="http://mcuoneclipse.com/2013/05/09/processor-expert-component-peupd-files-on-github/" title="http://mcuoneclipse.com/2013/05/09/processor-expert-component-peupd-files-on-github/"&gt;Processor Expert Component *.PEupd Files on GitHub | MCU on Eclipse&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;And if you want the 14-bit data, without Processor Expert component: you need to configure the F_MODE register as outlined by Mark Butcher.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 10:38:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317101#M13998</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2014-07-08T10:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317102#M13999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do I go about getting, &lt;STRONG&gt;F_Mode&lt;/STRONG&gt; &lt;SPAN style="text-decoration: underline;"&gt;not&lt;/SPAN&gt; set?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The F_Mode is confusing me if I'm honest. How can I understand this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 10:50:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317102#M13999</guid>
      <dc:creator>markadamson</dc:creator>
      <dc:date>2014-07-08T10:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317103#M14000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Acutally it is the F_READ bit. From the reference manual:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;5.2 8-bit or 14-bit Data&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The measured acceleration data is stored in the OUT_X_MSB, OUT_X_LSB, OUT_Y_MSB, OUT_Y_LSB, OUT_Z_MSB, and&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;OUT_Z_LSB registers as 2’s complement 14-bit numbers. The most significant 8-bits of each axis are stored in OUT_X (Y,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Z)_MSB, so applications needing only 8-bit results can use these 3 registers and ignore OUT_X,Y, Z_LSB. To do this, the&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;F_READ bit in CTRL_REG1 must be set. When the F_READ bit is cleared, the fast read mode is disabled.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The F_READ bit is in CTRL_REG1:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jiveImage" src="https://community.nxp.com/" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;So with the F_READ bit set, reading continuously from the memory map of the accelerometer will skip every second byte for the X, Y, Z values.&lt;/P&gt;&lt;P&gt;With that bit cleared, I can read the 16bit registers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is my code how I write that register:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14048187980997639 jive_text_macro jive_macro_code" jivemacro_uid="_14048187980997639" modifiedtitle="true"&gt;
&lt;P&gt;/*&lt;/P&gt;
&lt;P&gt;** ===================================================================&lt;/P&gt;
&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Method&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&amp;nbsp; MMA1_SetFastMode (component MMA8451Q)&lt;/P&gt;
&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Description :&lt;/P&gt;
&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Turns the F_READ (Fast Read Mode) on or off&lt;/P&gt;
&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parameters&amp;nbsp; :&lt;/P&gt;
&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - DESCRIPTION&lt;/P&gt;
&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - if to turn the F_READ mode on or off&lt;/P&gt;
&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Returns&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;/P&gt;
&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Error code&lt;/P&gt;
&lt;P&gt;** ===================================================================&lt;/P&gt;
&lt;P&gt;*/&lt;/P&gt;
&lt;P&gt;byte MMA1_SetFastMode(bool on)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t val, res;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; res = GI2C1_ReadByteAddress8(MMA8451_I2C_ADDR, MMA8451_CTRL_REG_1, &amp;amp;val);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if (res!=ERR_OK) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return res;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if (on) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; val |= MMA8451_F_READ_BIT_MASK; /* enable F_READ: Fast read mode, data format limited to single byte (auto increment counter will skip LSB) */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; } else {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; val &amp;amp;= ~MMA8451_F_READ_BIT_MASK; /* disable F_READ: Fast read mode, data format limited to single byte (auto increment counter will skip LSB) */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; return GI2C1_WriteByteAddress8(MMA8451_I2C_ADDR, MMA8451_CTRL_REG_1, val);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:09:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317103#M14000</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2020-11-02T13:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317104#M14001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ Erich&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have downloaded the &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;*.PEupd files&lt;/SPAN&gt; (although a download zip option is still not visible, I right clicked and saved link as. Only option I had to download these files) but when I import components, I get an error saying&amp;nbsp; " Import Processor Expert Package" has encountered a problem.....Corrupted update package. Unknown LZH header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have imported components before (the LED components for example, which I have been using)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 11:40:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317104#M14001</guid>
      <dc:creator>markadamson</dc:creator>
      <dc:date>2014-07-08T11:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317105#M14002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, unfortunately some browsers or proxies can cause corrupted files :-(&lt;/P&gt;&lt;P&gt;There is a zip file link on the GitHub root (&lt;A href="https://github.com/ErichStyger/mcuoneclipse/archive/master.zip" title="https://github.com/ErichStyger/mcuoneclipse/archive/master.zip"&gt;https://github.com/ErichStyger/mcuoneclipse/archive/master.zip&lt;/A&gt;), but be aware that will download the full repository snapshot (around 60 MB).&lt;/P&gt;&lt;P&gt;Probably the easiest way.&lt;/P&gt;&lt;P&gt;Otherwise you can download the raw files (click on the file, then select the raw button). I have pasted the links below:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/ErichStyger/mcuoneclipse/raw/master/PEupd/Part1_Beans_24.06.2014.PEupd" title="https://github.com/ErichStyger/mcuoneclipse/raw/master/PEupd/Part1_Beans_24.06.2014.PEupd"&gt;https://github.com/ErichStyger/mcuoneclipse/raw/master/PEupd/Part1_Beans_24.06.2014.PEupd&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/ErichStyger/mcuoneclipse/raw/master/PEupd/Part2_Beans_24.06.2014.PEupd" title="https://github.com/ErichStyger/mcuoneclipse/raw/master/PEupd/Part2_Beans_24.06.2014.PEupd"&gt;https://github.com/ErichStyger/mcuoneclipse/raw/master/PEupd/Part2_Beans_24.06.2014.PEupd&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 11:54:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317105#M14002</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2014-07-08T11:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317106#M14003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find that when I change modes (not just the 8/14 bit mode but also the sampling rate) it is necessary to power cycle the device before it accepts the change - do you find the same thing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also it looks like the PE generated code is only fully usable together with a pre-emptive operating system since it is blocking and so uses up the complete processor power for the I2C transfers. This allows the demo to operate but it couldn't work together in projects with various interfaces operating in parallel, especially when the accelerometer is being continuously read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:07:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317106#M14003</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-07-08T15:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317107#M14004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting strange values when outputting the xyz values. I am following your method of :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;unsigned short usX = ((array[0] &amp;lt;&amp;lt; 8) | array[1]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;unsigned short usY = ((array[2] &amp;lt;&amp;lt; 8) | array[3]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;unsigned short usZ = ((array[4] &amp;lt;&amp;lt; 8) | array[5]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;I am not clear on this process. Why are we shifting by 8 and ORing the shifted vales with the LSB?&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:18:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317107#M14004</guid>
      <dc:creator>markadamson</dc:creator>
      <dc:date>2014-07-08T15:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317108#M14005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark,&lt;/P&gt;&lt;P&gt;the data on the accelerometer is big endian, while the ARM core is little endian. The code swaps the bytes for the ARM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:21:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317108#M14005</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2014-07-08T15:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317109#M14006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;I have not noticed that it is necessary to power cycle the device, but I have not verified it neither (yet).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the driver code: it works fine for me in RTOS preemptive and bare metal way, as I can specify if I use it either interrupt driven (non-blocking) or in blocking/polling mode. I have used it in both ways, but typically for larger systems I'm using it with a pre-emptive operating system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:31:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317109#M14006</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2014-07-08T15:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317110#M14007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What values do you read from the 6 registers ? [X_MSB, X_LSB, Y_MSB, Y_LSB, and Z_MSB, Z_LSB]&lt;/P&gt;&lt;P&gt;If these are not corect also the 16 bit representations of them won't be good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also try a power cycle of the board before testing (if previously 8 bit mode was operating). I have found that this seems to be necessary otherwise the accelerometer is still operating in the old mode even though the new settings have been written to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:32:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317110#M14007</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-07-08T15:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317111#M14008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK. I just saw that the code was using things like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; while (!deviceData.dataReceivedFlg) {} /* Wait until data is received received */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so is presumably configured to use the blocking case, which would only be suiable for simple systems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 15:43:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317111#M14008</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-07-08T15:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317112#M14009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, I have noticed that you do have to power cycle the device. I thought it was just me for a while, but thanks for confirming that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the results, with the 8 bit output, I was getting XYZ values of maximum 127 and minimum -128.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, trying the 14 bit output, I am getting XYZ values of maximum 255. My understanding is that a 14 bit output, I should be getting a maximum value of 16383??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another strange observation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -5 Y =&amp;nbsp;&amp;nbsp; 7 Z =&amp;nbsp; 63 , these were results I obtained with the 8 bit output when the board is flat. This seems fine to me. But now, with the 14 bit output I am getting results: X =&amp;nbsp; 253 Y =&amp;nbsp;&amp;nbsp; 3 Z =&amp;nbsp; 63 when the board is flat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: Here are an updated set of results I have obtained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X = -12035 Y = -22523 Z = 4159 &lt;/P&gt;&lt;P&gt;X = -12035 Y = 28677 Z = 4159 &lt;/P&gt;&lt;P&gt;X = -12035 Y = 16389 Z = -10178 &lt;/P&gt;&lt;P&gt;X = 26877 Y = -32763 Z = -8130 &lt;/P&gt;&lt;P&gt;X = -32515 Y = 16389 Z = 8255 &lt;/P&gt;&lt;P&gt;X = -32515 Y = 20485 Z = 18495 &lt;/P&gt;&lt;P&gt;X = -16131 Y = -24571 Z = -4034 &lt;/P&gt;&lt;P&gt;X = 4350 Y = 28677 Z =&amp;nbsp; 63 &lt;/P&gt;&lt;P&gt;X = -20227 Y = 28677 Z = 22591 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It must be noted that these results are when the board is flat! Actually, I tried moving the board and the results I was obtaining wasn't changing to the orientation of the board. So these changing have no effect of the orientation of the board.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is clearly wrong and my understanding is most probably incorrect too unfortunately. I will have a further look this evening.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 16:00:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317112#M14009</guid>
      <dc:creator>markadamson</dc:creator>
      <dc:date>2014-07-08T16:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317113#M14010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 14 bit range is +8191/-8192 - but if left shifted (in 16 bits) it becomes (+32764/-32768).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is fastest if you zip the complete project and post it as attachment (activate advanced editor to use attachements) since it can be loaded to a FRDM-KL02Z and then the error immediately seen, so that the reason can be explained.&lt;/P&gt;&lt;P&gt;Posting snippets of code often doesn't help because the actual error is usually elsewhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 17:30:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317113#M14010</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-07-08T17:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317114#M14011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know the title of the folder is pulse_width_modulation, but its the project that I have been working on fairly recently, including trying to add pulse width modulation functionality. That isn't important right now though. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know your thoughts, I'm sure there will be plenty! :smileylaugh:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 15:27:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317114#M14011</guid>
      <dc:creator>markadamson</dc:creator>
      <dc:date>2014-07-09T15:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317115#M14012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problems that you have are general coding issues and nothing to do with the processor/accelerometer.&lt;/P&gt;&lt;P&gt;I made some corrections as follows so that it looks to basically work (RGB LED responds to tilt of board and the values printed out may be about what are expected).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res = MMA8451_ReadReg(MMA8451_OUT_X_MSB, &lt;SPAN style="color: #ff0000;"&gt;xyz, 6&lt;/SPAN&gt;); &lt;SPAN style="color: #ff0000;"&gt;// read 6 bytes (3 x 16 bit X,Y,Z results)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usXYZ[0] = ((xyz[0] &amp;lt;&amp;lt; 8) | xyz[1]); // convert X to 16 bit value (with 14 bit resolution)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usXYZ[1] = ((xyz[2] &amp;lt;&amp;lt; 8) | xyz[3]); // convert Y to 16 bit value (with 14 bit resolution)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usXYZ[2] = ((xyz[4] &amp;lt;&amp;lt; 8) | xyz[5]); // convert Z to 16 bit value (with 14 bit resolution)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RLED_Put(xyz[&lt;SPAN style="color: #ff0000;"&gt;0&lt;/SPAN&gt;]&amp;gt;50);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GLED_Put(xyz[&lt;SPAN style="color: #ff0000;"&gt;2&lt;/SPAN&gt;]&amp;gt;50);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BLED_Put(xyz[&lt;SPAN style="color: #ff0000;"&gt;4&lt;/SPAN&gt;]&amp;gt;50);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("X = %3d Y = %3d Z = %3d \n", usXYZ[0], usXYZ[1], usXYZ[2]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. You were only reading 3 byte (you must read 6 if in 14 bit mode)&lt;/P&gt;&lt;P&gt;2. You were reading the bytes to usXYZ which means that the values were stored in wrong format&lt;/P&gt;&lt;P&gt;3. Added the conversion between the byte values and the 16 bit value&lt;/P&gt;&lt;P&gt;4. The PWM can work with the 8 bit value as before (note the 0,2,4 for passed location to the R/G/B routines)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 16:13:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317115#M14012</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-07-09T16:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Re: FRDM - KL02Z - MMA8451Q 3-axis accelerometer</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317116#M14013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have implemented the changes you suggested, however, the values I am outputting on Putty terminal seem very random, and don't seem to be following the orientation of the board.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, when the board is flat on the table I get the following results,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X = -96 Y = -96 Z = 16144&lt;/P&gt;&lt;P&gt;X = -112 Y = -112 Z = 16200&lt;/P&gt;&lt;P&gt;X = -56 Y = 864 Z = -40&lt;/P&gt;&lt;P&gt;X = -64 Y = -112 Z = 16168&lt;/P&gt;&lt;P&gt;X = -128 Y = -112 Z = 16408&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Surely these values should be more consistent, i.e.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -5 Y =&amp;nbsp;&amp;nbsp; 7 Z =&amp;nbsp; 63 &lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -5 Y =&amp;nbsp;&amp;nbsp; 7 Z =&amp;nbsp; 63 &lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -5 Y =&amp;nbsp;&amp;nbsp; 6 Z =&amp;nbsp; 63 &lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -5 Y =&amp;nbsp;&amp;nbsp; 6 Z =&amp;nbsp; 63 &lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -5 Y =&amp;nbsp;&amp;nbsp; 7 Z =&amp;nbsp; 63 &lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -5 Y =&amp;nbsp;&amp;nbsp; 6 Z =&amp;nbsp; 62&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when flat on the table. These are results obtained with the 8 bit output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having said this, as I tilt the board in the XYZ orientations, the RGB outputs the correct colors. So what I did was change the printf statement to printf("X = %3d Y = %3d Z = %3d \n", xyz[0], xyz[2], xyz[4]); and I get the following results when the board is flat on the table: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -1 Y =&amp;nbsp;&amp;nbsp; 3 Z =&amp;nbsp; 63&lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -1 Y =&amp;nbsp;&amp;nbsp; 3 Z =&amp;nbsp; 63&lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -1 Y =&amp;nbsp;&amp;nbsp; 3 Z =&amp;nbsp; 63&lt;/P&gt;&lt;P&gt;X =&amp;nbsp; -1 Y =&amp;nbsp;&amp;nbsp; 3 Z =&amp;nbsp; 63&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I guess that makes sense. But in terms of outputting the 14 bit values on Putty terminal, its not working. Did you say you tested this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jul 2014 16:40:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-MMA8451Q-3-axis-accelerometer/m-p/317116#M14013</guid>
      <dc:creator>markadamson</dc:creator>
      <dc:date>2014-07-09T16:40:55Z</dc:date>
    </item>
  </channel>
</rss>

