AnsweredAssumed Answered

MMA8652FC FIFO Buffer

Question asked by Andrew S on Mar 6, 2015
Latest reply on Mar 9, 2015 by Tomas Vaverka

Hi, I'm trying to read from the FIFO Buffer off of the MMA8652FC Accelerometer.

 

I currently have it set up where the Buffer mode is set to be a Fill Buffer and the Watermark is set to 32 samples. I also have F_READ (Fast Read mode) enabled, so that the data I'm reading in is only 8-bits.

I do understand that whenever F_MODE is greater than 0, the OUT_X_MSB (0x01) register becomes the root pointer to XYZ FIFO data.

With this in mind, when I try to read and access the FIFO samples from OUT_X_MSB, it only returns 0x80 96 times. So it's clear I'm accessing the FIFO data improperly, however I cannot figure out why.

 

Note that I am able to access the data normally with the FIFO buffer disabled

 

The code I am using to read off of the FIFO is this:

 

void accel_BufRead(uint8* Data_Ptr){
  uint8 numBytes=96; //96 because I'm reading 32 samples of 8-bit XYZ data thus 32*3=96
   
  uint8 Write_Buf[1] = {0};
  uint8 *Write_Ptr = &Write_Buf;
  Write_Buf[0] = 0x01;


  I2C_1_MasterWriteBuf(Addr, Write_Ptr, 1, I2C_1_MODE_NO_STOP);//Addr is the slave address, Write_Ptr is the register address, I2C_1_MODE_NO_STOP
                                                               //indicates a mode where it will execute an I2C transfer without a Stop
    while(0u == (I2C_1_MasterStatus() & I2C_1_MSTAT_WR_CMPLT)){} //Check if the write process was successful and completed

  I2C_1_MasterReadBuf(Addr, Data_Ptr, numBytes, I2C_1_MODE_REPEAT_START);//Addr is the slave address, Data_Ptr is where the data will be stored,
                                                                         //numBytes= 96 bytes of data expected to read, I2C_MODE_REPEAT_START 
                                                                         //indicates mode where it will execute an I2C transfer 
                                                                         //by sending a Repeat Start instead of a Start
    while(0u == (I2C_1_MasterStatus() & I2C_1_MSTAT_RD_CMPLT)){} //Check if the read process was successful and completed
   
    return;
}

Outcomes