<?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 How to write a variable to a MMA8451 register using SDK 2.1? in Sensors</title>
    <link>https://community.nxp.com/t5/Sensors/How-to-write-a-variable-to-a-MMA8451-register-using-SDK-2-1/m-p/868175#M5500</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I would like to write a variable value to a threshold register in the MMA8451. Using SDK 2.1. The register write drivers are all set up to&amp;nbsp; use constants. For example, to write to the CTRL_REG1 you need to do all this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Each entry in a RegisterWriteList is composed of: register address, value to write, bit-mask to apply to write (0 enables)&lt;BR /&gt;const registerwritelist_t MMA845x_IDLE[] =&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; { MMA845x_CTRL_REG1, 0x00, 0x01 },&lt;BR /&gt;&amp;nbsp; &amp;nbsp; __END_WRITE_DATA__&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;int8_t MMA845x_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)&lt;BR /&gt;{&lt;BR /&gt; int32_t status;&lt;BR /&gt; if(sensor-&amp;gt;isInitialized == F_USING_ACCEL) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; status = Sensor_I2C_Write(sensor-&amp;gt;bus_driver, &amp;amp;sensor-&amp;gt;deviceInfo, sensor-&amp;gt;addr, MMA845x_IDLE );&lt;BR /&gt;&amp;nbsp; &amp;nbsp; sensor-&amp;gt;isInitialized = 0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; sfg-&amp;gt;Accel.isEnabled = false;&lt;BR /&gt; } else {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return SENSOR_ERROR_INIT;&lt;BR /&gt; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return status;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;And once you had all of that done you would use it by:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;global_I2C_status = MMA845x_IDLE(&amp;amp;(sensors[0]), &amp;amp;sfg);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the above method works well for writing a constant. However, I would like to write a variable. Could someone please be kind enough to help me out. I miss the good old days where something like&amp;nbsp;WriteI2CByte_MMA8451(MMA8451_CTRL_REG1,0x06) would work but I can not find anything simple like that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Feb 2026 21:06:36 GMT</pubDate>
    <dc:creator>marks</dc:creator>
    <dc:date>2026-02-03T21:06:36Z</dc:date>
    <item>
      <title>How to write a variable to a MMA8451 register using SDK 2.1?</title>
      <link>https://community.nxp.com/t5/Sensors/How-to-write-a-variable-to-a-MMA8451-register-using-SDK-2-1/m-p/868175#M5500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I would like to write a variable value to a threshold register in the MMA8451. Using SDK 2.1. The register write drivers are all set up to&amp;nbsp; use constants. For example, to write to the CTRL_REG1 you need to do all this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Each entry in a RegisterWriteList is composed of: register address, value to write, bit-mask to apply to write (0 enables)&lt;BR /&gt;const registerwritelist_t MMA845x_IDLE[] =&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; { MMA845x_CTRL_REG1, 0x00, 0x01 },&lt;BR /&gt;&amp;nbsp; &amp;nbsp; __END_WRITE_DATA__&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;int8_t MMA845x_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)&lt;BR /&gt;{&lt;BR /&gt; int32_t status;&lt;BR /&gt; if(sensor-&amp;gt;isInitialized == F_USING_ACCEL) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; status = Sensor_I2C_Write(sensor-&amp;gt;bus_driver, &amp;amp;sensor-&amp;gt;deviceInfo, sensor-&amp;gt;addr, MMA845x_IDLE );&lt;BR /&gt;&amp;nbsp; &amp;nbsp; sensor-&amp;gt;isInitialized = 0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; sfg-&amp;gt;Accel.isEnabled = false;&lt;BR /&gt; } else {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return SENSOR_ERROR_INIT;&lt;BR /&gt; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return status;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;And once you had all of that done you would use it by:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;global_I2C_status = MMA845x_IDLE(&amp;amp;(sensors[0]), &amp;amp;sfg);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the above method works well for writing a constant. However, I would like to write a variable. Could someone please be kind enough to help me out. I miss the good old days where something like&amp;nbsp;WriteI2CByte_MMA8451(MMA8451_CTRL_REG1,0x06) would work but I can not find anything simple like that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2026 21:06:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/How-to-write-a-variable-to-a-MMA8451-register-using-SDK-2-1/m-p/868175#M5500</guid>
      <dc:creator>marks</dc:creator>
      <dc:date>2026-02-03T21:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a variable to a MMA8451 register using SDK 2.1?</title>
      <link>https://community.nxp.com/t5/Sensors/How-to-write-a-variable-to-a-MMA8451-register-using-SDK-2-1/m-p/868176#M5501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Never mind. I ended up just defining 5 constants as thresholds and used those.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for reading!&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2019 20:16:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/How-to-write-a-variable-to-a-MMA8451-register-using-SDK-2-1/m-p/868176#M5501</guid>
      <dc:creator>marks</dc:creator>
      <dc:date>2019-01-29T20:16:08Z</dc:date>
    </item>
  </channel>
</rss>

