BMI270 reading of fifo data via SPI working in zephyr

Hi,

I am developing a custom board with nrf5340 SoC (nrfConnect SDK/zephyr) communicating with BMI270 via 8 MHz SPI. From BMI270 side I only need the high quality data, no detection algo or anything else.

The only thing I cannot get to work so far is reading the content of the FIFO.

The entire firmware works without FIFO already (interrupts, data readout, readout and configuration of all registers) - so, if I would not sometimes loose a frame (due to a variation in timing within my algo), I would not really need the FIFO to work but stay completely synchronous. Since the BMI270 implementation in zephyr is kind of rudimentary not fulfilling all my needs, I am directly reading and writing registers (single byte or multibyte) using the lower level functionality given in the zephyr driver source (see below).

Now I am at the point, that I can setup FIFO mode: I have headerless dataframes of 12 byte (acc and gyr), so the FIFO length nicely goes up in steps of 12... when the FIFO is full, interrupt 2 is triggered fine and the length stays the same from then on.

BUT: no matter when and with how many bytes I try to read the FIFO data gegister - I get strange results that seem to have nothing to do with the sensor data... but I do not get any error.

=> I have seen, that there are some variants of the configuration file (I am using the "basic" version, implemented in the zephyr driver so far).

Is the version I use made for FIFO use? It looks like there is a different one used at least in some (but seemingly not all) BMI270 samples published by BST.

=> Is there a "low level" sample for reading from the FIFO Data register via SPI using e.g. the Bosch Sensortech code in bmi270_spi.c

static int bmi270_reg_read_spi(const union bmi270_bus *bus, uint8_t start, uint8_t *data, uint16_t len)

The method implemented there is what I use successfully for all other register reads so far...

=> Is the method for reading Data from the FIFO data register different from other registers?


Thank you very much for any help on this!

mshape

Best reply by mshape

Hi BSTRobin,

I finally understood the problem - it lies within the zephyr driver for BMI270 - actually directly in the function bmi270_reg_read_spi. This function does not use the burst read functionality of the sensor, but emulates a burst read by reading single registers in a loop with INCREASING address very inefficiently. Therefore it cannot be used for a single register read of multiple sequential bytes. It can very easily changed to burst read - I just was interpreting the rather (unnecessarily?) complex way it was implemented to be necessary. I stll do not understand, why it has been implemented in this way in the zephyr driver, but after my changes for my implementation it works now.

=> so: source of problem understood and solution implemented => high speed and works fine now!

Thanks,

mshape

View original
3 replies
Resolved