Unable to work the MMA8652 self test

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

Unable to work the MMA8652 self test

Jump to solution
1,235 Views
samc
Contributor III

Hello,

I try to use the self test of MMA8652 without success. The component returns the same value in self test mode as in normal mode.

My procedure :

- Set Active Mode (Control Register 1 = 0x019 / Control Register 2 = 0x00 / XYZ Data Config Register = 0x02)

-  Read 3 axis in non self test mode

- Set Self test mode (Control Register 1 = 0x019 / Control Register 2 = 0x80 / XYZ Data Config Register = 0x02)

-  Read 3 axis in self test mode

- Set Standby mode (Control Register 1 = 0x018 / Control Register 2 = 0x00 / XYZ Data Config Register = 0x02)

- Compare

I don't find why it doesn't work, do I forget something ? delay, bad config, etc....

Sam,

0 Kudos
Reply
1 Solution
1,028 Views
david_diaz
NXP Employee
NXP Employee

Hello Sam,

In order to set the Self-Test, I recommend using the procedure below:

      

       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, 0x82);                   // Self test enabled, High Resolution mode

       I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG1, 0x19);                   // ODR = 100Hz, Active mode

 

After the procedure mentioned, you may read the data registers in order to notice the electrostatic actuation force applied to the sensor.

I hope this information helps.

Best Regards,

David

View solution in original post

0 Kudos
Reply
5 Replies
1,028 Views
samc
Contributor III

Sorry I didn't see it in the datasheet...

0 Kudos
Reply
1,028 Views
samc
Contributor III

Hello,

Thank you for your feedback. I apply your recommandations and it works but I think I had a timing problem. When I launched a reading after the activation it didn't work, I have the same values in self test and not in self test + no variations. So I added a little delay after activation, several ms and it's OK. For example with a delay of 5ms it doesn't work...I don't see information in the datasheet, is it normal ?

0 Kudos
Reply
1,028 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello Sam,

Since there is a transition from Standby to Active mode, it is necessary to take into account the Ton1 time:

Ton1.JPG

If ODR = 100Hz, it takes 2/100 + 1 = 21ms.

Best regards,

Tomas

0 Kudos
Reply
1,028 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hello Sam,

Looking at your procedure, you are activating the self-test when the MMA8652FC is in the Active mode. This is not correct, you need to set the Standby mode first, activate the self-test by setting the ST bit in the CTRL_REG2 register and then set the Active mode again.

Hope it helps.

Best regards,

Tomas 

0 Kudos
Reply
1,029 Views
david_diaz
NXP Employee
NXP Employee

Hello Sam,

In order to set the Self-Test, I recommend using the procedure below:

      

       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, 0x82);                   // Self test enabled, High Resolution mode

       I2C_WriteRegister(MMA845x_I2C_ADDRESS, CTRL_REG1, 0x19);                   // ODR = 100Hz, Active mode

 

After the procedure mentioned, you may read the data registers in order to notice the electrostatic actuation force applied to the sensor.

I hope this information helps.

Best Regards,

David

0 Kudos
Reply