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,
已解决! 转到解答。
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
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 ?
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
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