05-11-2020 03:30 PM - edited 05-11-2020 03:32 PM
If we look the picture below we can see that the last sample retrieved from the FIFO is not read completely.
I have investigated and see that for the function bma400_get_regs the number of dummy byte is added to the actual number of byte we want to read:
int8_t bma400_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint8_t len, const struct bma400_dev *dev)
{
int8_t rslt;
uint16_t index;
uint16_t temp_len = len + dev->dummy_byte;
uint8_t temp_buff[temp_len];
...
/* Read the data from the reg_addr */
rslt = dev->read(dev->dev_id, reg_addr, temp_buff, temp_len);
...
}
but this is not done into the function read_fifo:
static int8_t read_fifo(const struct bma400_fifo_data *fifo, const struct bma400_dev *dev)
{
int8_t rslt;
uint8_t reg_data;
uint8_t fifo_addr = BMA400_FIFO_DATA_ADDR;
...
rslt = dev->read(dev->dev_id, fifo_addr, fifo->data, fifo->length);
...
}
int8_t bma400_get_fifo_data(struct bma400_fifo_data *fifo, const struct bma400_dev *dev)
{
int8_t rslt;
uint8_t data;
uint16_t fifo_byte_cnt = 0;
uint16_t user_fifo_len = 0;
...
/* Reading the FIFO length */
rslt = get_fifo_length(&fifo_byte_cnt, dev);
if (rslt == BMA400_OK)
{
...
user_fifo_len = fifo->length;
if (fifo->length > fifo_byte_cnt)
{
/* Handling case where user requests
* more data than available in FIFO
*/
fifo->length = fifo_byte_cnt;
}
...
rslt = read_fifo(fifo, dev);
}
...
}
by adding the number of dummy bytes into fifo_byte_cnt the problem was fixed.
This issue is present on the commit: https://github.com/BoschSensortec/BMA400-API/commit/f87f5ec1b91db7a9f7fb55e777d2a3d8ab99d7db
Solved! Go to Solution.
05-11-2020 04:11 PM
Hi,
Thank you for your feedback. We will investigate the BMA400 Driver on the Github. If it is true that the first dummy byte is missing when reading FIFO data through SPI interface, then we will get back to you.
Thanks.
05-25-2020 06:40 PM
Hello,
Do you have any news?
Best regards,
Cyril Praz
05-29-2020 11:38 PM
Hello
Just to check a couple of things to better help you.
1) what is the ODR used for the issue concerned?
2) are you using i2c/spi to talk to the sensor?
3) did you enable fifo_time_en in FIFO_CONFIG0 (register 0x26), when reading FIFO, it's suggested to enable fifo_time_en bit so that you get the sensortime frame which is an indication the sensor fifo is completely read out
The FIFO is automatically filled even during the time when you are reading out the samples from it, so it could be possible that: if the reading out is on the verge of a new sample arrival, after the read out, the FIFO is not drained compeletely, this is usually the case when: the system is very busy, and read out of the FIFO is delayed long after latest sample is available, or if the ODR is high and a very slow bus is used(e.g.: 100khz I2C), so to address this kind of tricky timing issue (from the host), the driver tries to overread a bit.
``
if ((fifo->fifo_time_enable == BMA400_ENABLE) &&
(fifo_byte_cnt + BMA400_FIFO_BYTES_OVERREAD <= user_fifo_len))
{
/* Handling sensor time availability*/
fifo->length = fifo->length + BMA400_FIFO_BYTES_OVERREAD;
}
``
BMA400_FIFO_BYTES_OVERREAD is currently defined as 25, please note that it's a number with tradeoff between traffic size and changes of improving the issue, if this number is very big, then you can almost guarrantee that everytime you can drain the fifo completely, but the overhead on the bus traffic is higher, vice versa.
and the number 25 has already covered the dummy byte.
but this overread only is applied when the fifo_time_en bit is set.
Hope this helps.
06-24-2020 04:58 PM
Hi Cyril Praz,
Is the issue resolved? If yes, then please click "Accept as Solution" button to close this case.
Thanks.