Author Topic: MPU-9150 FIFO Mode  (Read 3729 times)

0 Members and 1 Guest are viewing this topic.

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
MPU-9150 FIFO Mode
« on: November 13, 2014, 04:39:08 pm »
Hello all,

for a current project that I'm working I need to interface to a MPU-9150 9 axis IMU.

I've been reading the documentation and there are two possible ways to read data, directly from the registers or using a FIFO.

This is where my doubts are, in the datasheet "FIFO_R_W" (address 116) allows reading from the FIFO, but this is an I2C device, so if I read the first byte I'll read address 116 and the second byte read should be address 117, but address 117 is a "WHO AM I" register (constant).

I saw in this code https://github.com/kriswiner/MPU-9150/blob/master/STM32F401/MPU9150.h line 446 that they just perform a normal read to addr 116 asking for multiple bytes.

My question is, is this a special register? won't the MPU-9150 auto increment the internall I2C address that I'm reading?

Thanks in advanced,
best regards, Mauro.
« Last Edit: November 13, 2014, 04:43:38 pm by maurosmartins »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: MPU-9150 FIFO Mode
« Reply #1 on: November 13, 2014, 11:22:42 pm »
You are overthinking it: enable the fifo and read it and see if the pointer increments.
================================
https://dannyelectronics.wordpress.com/
 

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
Re: MPU-9150 FIFO Mode
« Reply #2 on: November 14, 2014, 09:29:48 am »
Hello dannyf and thank you for your reply,

you are probably right, I'll test it as soon as I can,

the reason for me to post here was hopping some user had already worked with this.

Thanks anyway,

best regards, Mauro.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3436
  • Country: gb
Re: MPU-9150 FIFO Mode
« Reply #3 on: November 14, 2014, 11:49:34 am »
The datasheet implies that the FIFO register does not auto-increment if repeated reads are made (it says the FIFO register supports "burst" reads)  though I agree this is not very clear.
 

Offline maurosmartinsTopic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: pt
    • Electronics and Embedded systems
Re: MPU-9150 FIFO Mode
« Reply #4 on: November 14, 2014, 12:07:55 pm »
Hello mikerj,

that is also my thoughts, thank you for your reply!

Best regards, Mauro.
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: MPU-9150 FIFO Mode
« Reply #5 on: November 15, 2014, 05:13:57 am »
Just read the number of bytes you want starting from that register.

Code: [Select]
bool MPU9150::read_fifo_data(uint16_t &count, uint8_t *buffer) {
    if (!read(FIFO_COUNT_H, count)) return false;
    count = byteswap16(count);

    assert(count <= 1024);

    return bus.read(address, FIFO_R_W, buffer, count, 100);
}
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf