Hi,
I'm working with the same accelerometer (MMA8453) and i'm expecting exactly the same issue. I already tried a simple code where i'm reading the accelerometer values every time a flag is triggered in the interruption. After it I read the interruption register to clean the interrupt flag. After some time working, my accelerometer stops working and, using a digital analizer, I saw it was the interruption pin that was blocked in low.
Here is some parts of the code where you can see how it was implemented. I already tried to enable the Transient mode but stills not working properly.
```
/** * configure * @brief Accelerometer configuration. * To configure the MMA8453 set it to Standby mode, perform the * modifications and change it back to Active mode. * * @param none * * @return none * */ void CMMA8453::configure() { /* MMA8453 configuration for Data Ready mode */
/* Set the module in standby mode to configure it */
this->sleep();
/* Set full-scale range to 2G */
this->writeByte(REG_XYZ_DATA_CFG_ADDRESS, REG_RANGE_2G_VALUE);
/* Configure Transient */
this->writeByte(REG_TRANSIENT_CFG_ADDRESS, REG_TRANSIENT_ELE_VALUE);
/* Data Ready mode */
this->writeByte(REG_CTRL_REG2_ADDRESS, REG_CTRL_REG2_NORMAL_MODE_VALUE);
/* Set open drain on interrupt pad */
this->writeByte(REG_CTRL_REG3_ADDRESS, REG_CTRL_REG3_OPEN_DRAIN_WAKE_TRANSIENT_VALUE);
/* Enable data ready interrupt */
this->writeByte(REG_CTRL_REG4_ADDRESS, REG_CTRL_REG4_DATA_READY_TRANSIENT_INT_EN_VALUE);
/* Route interrupt to INT1 pin */
this->writeByte(REG_CTRL_REG5_ADDRESS, REG_CTRL_REG5_DATA_READY_INT2_VALUE);
/* Set the module in active mode to start collecting data */
this->wakeUp(); }
/**
* hasNewData
* @brief Check if new accelerometer data is available
*
* @param none
*
* @return true if new data is available
* false if new data is not available
*
**/
bool
CMMA8453::hasNewData()
{
/* Request interrupt source */
uint8_t interruptSource = 0;
uint8_t interruptTransient = 0;
if (true == this->has_interrupt_occured ) {
/* Clear interrupt flags*/
this->readByte(REG_TRANSIENT_SRC_ADDRESS, &interruptTransient);
this->readByte(REG_INT_SOURCE_ADDRESS, &interruptSource);
/* Handle interrupt data is ready */
if ((interruptSource & REG_SRC_DATA_READY_VALUE) == REG_SRC_DATA_READY_VALUE) {
/* Signal that new data is available */
return true;
}
}
return false;
}
/**
* sleep
* @brief Put the accelerometer in standby mode
*
* @param none
*
* @return none
*
**/
void
CMMA8453::sleep()
{
/* Set output data rate (ODR) to 6.25Hz and Standby mode */
this->writeByte(REG_CTRL_REG1_ADDRESS, (REG_CTRL_REG1_6Hz_VALUE | REG_CTRL_REG1_STANDBY_VALUE));
}
/**
* wakeUp
* @brief Put the accelerometer in active mode
*
* @param none
*
* @return none
*
**/
void
CMMA8453::wakeUp()
{
/* Set output data rate (ODR) to 6.25Hz and Active mode */
this->writeByte(REG_CTRL_REG1_ADDRESS, (REG_CTRL_REG1_6Hz_VALUE | REG_CTRL_REG1_ACTIVE_VALUE));
}
/**
* interruptHandler
* @brief Handles the Interrupt by checking the interrupt source
* and acts accordingly.
*
* @param none
*
* @return none
*
**/
void
CMMA8453::interruptHandler()
{
/* Disable Interrupt */
nrf_drv_gpiote_in_event_disable(CGPIO::INT1_ACC);
this->has_interrupt_occured = true;
/* Enable Interrupt */
nrf_drv_gpiote_in_event_enable(CGPIO::INT1_ACC, true);
}