AnsweredAssumed Answered

mma8451& FIFO buffer

Question asked by Alessio Galli on Dec 14, 2018
Latest reply on Dec 18, 2018 by Tomas Vaverka

Hi,

I'm using the MMA8451 to make a tilt sensor.

Everything is Arduino based using the classic ATmega328P.

 

My intention is to use the FIFO buffer to get it full with 32 samples @ 800HZ in active mode without any sleep function.

 

In the setup function I set the register like this:

  writeRegister8(MMA8451_REG_CTRL_REG2, 0x40); // reset

  while (readRegister8(MMA8451_REG_CTRL_REG2) & 0x40);

  writeRegister8(MMA8451_REG_CTRL_REG1, 0x00);     // Standby mode (DEACTIVE) @ 800Hz
  writeRegister8(MMA8451_REG_FIFO_SETUP, 0x60);    // FIFO in circular buffer. watermark set to 32
  writeRegister8(MMA8451_REG_CTRL_REG2, 0x02);     // High resolution
  writeRegister8(MMA8451_REG_CTRL_REG3, 0x02);     // push-pull active-high
  writeRegister8(MMA8451_REG_CTRL_REG4, 0x40);     // FIFO interrupt enabled
  writeRegister8(MMA8451_REG_CTRL_REG5, 0x40);     // Interrupt is routed to INT1 pin
  writeRegister8(MMA8451_REG_CTRL_REG1, 0x01);     // Active mode and reduced noise mode. ODR = 800Hz

 

  attachInterrupt(0, INT0_ISR, RISING);      // for the accelerometer FIFO register reading

 

and at the beginning I have the interrupt where I would have to read all the 32 samples.

 

void INT0_ISR()
{

  // For an I2C bit rate of 400 kHz, FIFORead(32) + 3 μs = 4.878 ms.
  for (byte i=1; i<=OSR; i++)
  {
    // Read the 'raw' data in 14-bit counts
    readAcceleration(&x, &y, &z);

  }

 

But anything works because I'm not able to get the buffer empty reading all the values.

Basically the interrupt pin stays high forever.

 

Even I tried to clear the flag interrupt without success

  readRegister8(MMA8451_REG_INT_SOURCE);
  readRegister8(MMA8451_REG_FIFO_STATUS);

 

Then anyone is able to help me ?

 

Thanks in advance to everyone who spends time for this.

Outcomes