Accelerometer and Magnetometer FIFO usage (FXOS8700CQ)

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

Accelerometer and Magnetometer FIFO usage (FXOS8700CQ)

1,190 Views
alexandertorofi
Contributor I

Hello,

I am integrating FXOS8700CQ , 6-Axis Sensor with Integrated Linear Accelerometer and Magnetometer and I am interested in acc. and mag. data, buffered with 100Hz sample rate and read each 50 ms, 14-bit data mode.

As far I can see FIFO functionallity sadly does not include buffering of mag. data, so for 50 ms I can get 5 samples for acc. and 1 for compass.My questions are:

- if I rely on autoincrement, starting from status (0x00), will the autoincrement point me to magnetic data (0x33)? Speaking in register addresses, (0x) 0, 1,2,3,4,5,6, 1,2,3,4,5,6, 1,2,3,4,5,6, 1,2,3,4,5,6, 1,2,3,4,5,6, 33,34,35,36,37,38.

And what will happen if a new sample is done while I am reading the other 5 - will the pointer direct me to 1 again, instead of 0x33 after 5 FIFO packets are read or maybe again towards 1 or 0?

Thanks in advance for your support!

Labels (2)
0 Kudos
3 Replies

569 Views
david_diaz
NXP Employee
NXP Employee

Hello Alexander,

As you mentioned, the FXOS87OOCQ counts with 32-sample FIFO for acceleration data only.

If the FIFO data output register driver is enabled STATUS[f_mode] > 00, register 0x01 points to the head of the FIFO buffer, while registers 0x02, 0x03, 0x04, 0x05, 0x06 return a value of zero when read directly.

It means that if you pretend to enable the FIFO, STATUS[f_mode] > 00, the register 0x01, which is OUT_X_MSB, will contain the previous 32 X, Y, and Z data samples.

If you disable the FIFO, STATUS[f_mode] = 00, and you read directly the sample data registers, indeed, the behavior is done as you mentioned.

In case you disable the FIFO, please be aware about the CTRL_REG1[f_read] register.

Have a great day. :smileyhappy:

David Diaz.

Note: If this post answers your question, please click the Correct Answer button. Thank you!

0 Kudos

569 Views
alexandertorofi
Contributor I

Hello,

Thank you for your reply and time. I agree with you, but what I meant is if I have FIFO active, read the status (0x00), see that I have 5 new packets in FIFO, point at 0x01 and then read continously 36 bytes (6x6), which will be the last 6 bytes read?

Or when I read the last of the buffered packeds in FIFO, where will the autoincrement take me for the last 6 bytes? Will it automatically take me to 0x33? Will it take me to the oldest buffered data, considering that this is a ring buffer? Will it just give me zeroes, since I've already read the 30 bytes I have in FIFO? And what will happen if a new 6 bytes for the accelerometer arrive after I've read the Status?

Meanwhile, I've taken the safer road and don't rely on the autoincrement. I simply point to the compass after I get the acc data, but sill, out of curiousity (and because of possible optimization) I am interested what the autoincrement does when FIFO is read.

    GetAxlmData();

    I2C_Read(FXOS8700CQ_SLAVE_ADDR, FXOS8700CQ_MAG_X1_MSB, sensorData.cmpsData[0].Ch, 6); //get compass data

    I2C_Read(FXOS8700CQ_SLAVE_ADDR, FXOS8700CQ_TEMP, (unsigned char*)&sensorData.temperature, 1); //get compass data

Kind regards,

Alex

0 Kudos

569 Views
david_diaz
NXP Employee
NXP Employee

Hello Alexander,

Please accept my apologies for the delayed response.

Indeed, the FIFO overflow is asserted every 32 samples. In this case we have the option of flushing either the 14-bit data or the 8-bit data.

For the 14-bit data each sample consists of three 14-bit values, each stored as 2 bytes. Therefore, when full, the FIFO will contain 192 bytes. For the 8-bit data each sample consists of three 8-bit values, each stored as 1 byte. Therefore in this case when full the FIFO will contain 96 bytes.

In regard with the FIFO behavior, please be aware about the FIFO buffer operating modes:

  1. f_mode= 01 Circular Buffer: In this mode the FIFO contains the most recent samples when overflowed. The oldest sample is discarded to be replaced by the new sample. This mode is useful when waiting for an event and wanting to collect the latest 32 samples up to that event.
  2. f_mode = 10 Fill Buffer: In this mode the FIFO stops accepting new samples when overflowed. This is a good mode to be in for data logging.
  3. f_mode = 11 Trigger Buffer: In this mode the FIFO will be in a circular mode up to the number of samples set in the watermark.

For more information on using the FIFO buffer and the various FIFO operating modes, please refer to Freescale application note AN4073​.

Please let me know if this information is useful for you.

If I misunderstood your question, feel free to let me know.  I will be glad to help.

Have a great day.

David Diaz.

0 Kudos