<?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>Embedded Software and Tools Clinic中的主题 MMA8452Q</title>
    <link>https://community.nxp.com/t5/Embedded-Software-and-Tools/MMA8452Q/m-p/1591322#M339</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I am using MMA8452QR1 with STM32, and for communication I2C protocol is using.&lt;/P&gt;&lt;P&gt;I am trying to get the motion detection of accelerometer&lt;/P&gt;&lt;P&gt;But while writing an register FF_MT_CFG (0x15) = 0xD8 ;&lt;/P&gt;&lt;P&gt;it did not write that value but instead of that (0x50) value written on that register.&lt;/P&gt;&lt;P&gt;the configuration of register for MMA8452Q is as follows,&lt;/P&gt;&lt;P&gt;CTRL_REG (0x2A) = 0x01;&lt;/P&gt;&lt;P&gt;FF_MT_COUNT(0x18) = 0x02;&lt;/P&gt;&lt;P&gt;XYZ_DATA_CFG (0x0E) = 0x00;&lt;/P&gt;&lt;P&gt;FF_MT_THS (0x17) = 0x85;&lt;/P&gt;&lt;P&gt;Code is as Follows,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define ACC_ADD 0x1D&lt;BR /&gt;#define ACC_MOD_REG 0x2A&lt;BR /&gt;#define ACC_DATA_CONFIG_REG 0x0E&lt;BR /&gt;#define ACC_MOT_CFG_REG 0x15&lt;BR /&gt;#define ACC_MOT_DET_STATUS 0x16&lt;BR /&gt;#define ACC_DATA_REG_X 0x01&lt;BR /&gt;#define ACC_DATA_REG_Y 0x03&lt;BR /&gt;#define ACC_DATA_REG_Z 0x05&lt;BR /&gt;#define ACC_MOT_DEBOUNCE_COUNT 0x18&lt;BR /&gt;#define ACC_MOT_THS 0x17&lt;/P&gt;&lt;P&gt;extern I2C_HandleTypeDef hi2c1 ;&lt;BR /&gt;/*&lt;BR /&gt;@brief receives data from accelerometer of acceleration co-ordinate &amp;amp; motion detection&lt;BR /&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/38121"&gt;@para&lt;/a&gt;acc_axis_data_t holds acceleration data of X-Y-Z axis&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void acc_init()&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;uint8_t buf[5] = {0} ;&lt;BR /&gt;uint8_t bufTemp[5] = {0};&lt;/P&gt;&lt;P&gt;buf[0]=0x01;&lt;/P&gt;&lt;P&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1, ACC_MOD_REG, I2C_MEMADD_SIZE_8BIT, &amp;amp;buf[0], 1, 10) == HAL_OK) // active mode select&lt;BR /&gt;{&lt;BR /&gt;HAL_Delay(100);&lt;BR /&gt;buf[0] = 0;&lt;BR /&gt;HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_MOD_REG , I2C_MEMADD_SIZE_8BIT, buf, 1 , 10);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;buf[0]=0xD8;&lt;BR /&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1, ACC_MOT_CFG_REG, I2C_MEMADD_SIZE_8BIT,&amp;amp;buf[0] , 1, 10) == HAL_OK) // config of motion detection&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;BR /&gt;if(HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_MOT_CFG_REG , I2C_MEMADD_SIZE_8BIT, bufTemp, 1 , 10) == HAL_OK)&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;buf[0]=0x02;&lt;BR /&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt; 1 , ACC_MOT_DEBOUNCE_COUNT, I2C_MEMADD_SIZE_8BIT, &amp;amp;buf[0], 1, 10) == HAL_OK) //&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;/P&gt;&lt;P&gt;HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_MOT_DEBOUNCE_COUNT , I2C_MEMADD_SIZE_8BIT, buf, 1 , 10);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;buf[0]=0x00;&lt;BR /&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt; 1 , ACC_DATA_CONFIG_REG, I2C_MEMADD_SIZE_8BIT, &amp;amp;buf[0], 1, 10) == HAL_OK) //&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;/P&gt;&lt;P&gt;HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_DATA_CONFIG_REG , I2C_MEMADD_SIZE_8BIT, buf, 1 , 10);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;buf[0]=0x85;&lt;BR /&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt; 1 , ACC_MOT_THS, I2C_MEMADD_SIZE_8BIT, &amp;amp;buf[0], 1, 10) == HAL_OK) //&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;/P&gt;&lt;P&gt;HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_MOT_THS , I2C_MEMADD_SIZE_8BIT, buf, 1 , 10);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pranal .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Feb 2023 12:04:25 GMT</pubDate>
    <dc:creator>Pranal_m</dc:creator>
    <dc:date>2023-02-03T12:04:25Z</dc:date>
    <item>
      <title>MMA8452Q</title>
      <link>https://community.nxp.com/t5/Embedded-Software-and-Tools/MMA8452Q/m-p/1591322#M339</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I am using MMA8452QR1 with STM32, and for communication I2C protocol is using.&lt;/P&gt;&lt;P&gt;I am trying to get the motion detection of accelerometer&lt;/P&gt;&lt;P&gt;But while writing an register FF_MT_CFG (0x15) = 0xD8 ;&lt;/P&gt;&lt;P&gt;it did not write that value but instead of that (0x50) value written on that register.&lt;/P&gt;&lt;P&gt;the configuration of register for MMA8452Q is as follows,&lt;/P&gt;&lt;P&gt;CTRL_REG (0x2A) = 0x01;&lt;/P&gt;&lt;P&gt;FF_MT_COUNT(0x18) = 0x02;&lt;/P&gt;&lt;P&gt;XYZ_DATA_CFG (0x0E) = 0x00;&lt;/P&gt;&lt;P&gt;FF_MT_THS (0x17) = 0x85;&lt;/P&gt;&lt;P&gt;Code is as Follows,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define ACC_ADD 0x1D&lt;BR /&gt;#define ACC_MOD_REG 0x2A&lt;BR /&gt;#define ACC_DATA_CONFIG_REG 0x0E&lt;BR /&gt;#define ACC_MOT_CFG_REG 0x15&lt;BR /&gt;#define ACC_MOT_DET_STATUS 0x16&lt;BR /&gt;#define ACC_DATA_REG_X 0x01&lt;BR /&gt;#define ACC_DATA_REG_Y 0x03&lt;BR /&gt;#define ACC_DATA_REG_Z 0x05&lt;BR /&gt;#define ACC_MOT_DEBOUNCE_COUNT 0x18&lt;BR /&gt;#define ACC_MOT_THS 0x17&lt;/P&gt;&lt;P&gt;extern I2C_HandleTypeDef hi2c1 ;&lt;BR /&gt;/*&lt;BR /&gt;@brief receives data from accelerometer of acceleration co-ordinate &amp;amp; motion detection&lt;BR /&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/38121"&gt;@para&lt;/a&gt;acc_axis_data_t holds acceleration data of X-Y-Z axis&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void acc_init()&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;uint8_t buf[5] = {0} ;&lt;BR /&gt;uint8_t bufTemp[5] = {0};&lt;/P&gt;&lt;P&gt;buf[0]=0x01;&lt;/P&gt;&lt;P&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1, ACC_MOD_REG, I2C_MEMADD_SIZE_8BIT, &amp;amp;buf[0], 1, 10) == HAL_OK) // active mode select&lt;BR /&gt;{&lt;BR /&gt;HAL_Delay(100);&lt;BR /&gt;buf[0] = 0;&lt;BR /&gt;HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_MOD_REG , I2C_MEMADD_SIZE_8BIT, buf, 1 , 10);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;buf[0]=0xD8;&lt;BR /&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1, ACC_MOT_CFG_REG, I2C_MEMADD_SIZE_8BIT,&amp;amp;buf[0] , 1, 10) == HAL_OK) // config of motion detection&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;BR /&gt;if(HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_MOT_CFG_REG , I2C_MEMADD_SIZE_8BIT, bufTemp, 1 , 10) == HAL_OK)&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;buf[0]=0x02;&lt;BR /&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt; 1 , ACC_MOT_DEBOUNCE_COUNT, I2C_MEMADD_SIZE_8BIT, &amp;amp;buf[0], 1, 10) == HAL_OK) //&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;/P&gt;&lt;P&gt;HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_MOT_DEBOUNCE_COUNT , I2C_MEMADD_SIZE_8BIT, buf, 1 , 10);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;buf[0]=0x00;&lt;BR /&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt; 1 , ACC_DATA_CONFIG_REG, I2C_MEMADD_SIZE_8BIT, &amp;amp;buf[0], 1, 10) == HAL_OK) //&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;/P&gt;&lt;P&gt;HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_DATA_CONFIG_REG , I2C_MEMADD_SIZE_8BIT, buf, 1 , 10);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;buf[0]=0x85;&lt;BR /&gt;if (HAL_I2C_Mem_Write(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt; 1 , ACC_MOT_THS, I2C_MEMADD_SIZE_8BIT, &amp;amp;buf[0], 1, 10) == HAL_OK) //&lt;BR /&gt;{&lt;BR /&gt;buf[0] = 0;&lt;/P&gt;&lt;P&gt;HAL_I2C_Mem_Read(&amp;amp;hi2c1, ACC_ADD &amp;lt;&amp;lt;1 , ACC_MOT_THS , I2C_MEMADD_SIZE_8BIT, buf, 1 , 10);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pranal .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 12:04:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Embedded-Software-and-Tools/MMA8452Q/m-p/1591322#M339</guid>
      <dc:creator>Pranal_m</dc:creator>
      <dc:date>2023-02-03T12:04:25Z</dc:date>
    </item>
  </channel>
</rss>

