We are using an arduino to read data from the ADXL345 at 25Hz. The ADXL345 is in FIFO mode and originally we were using I2C to read 25 registers from the ADXL every second. It would take a second to get 25 readings, but there was a 25ms time delay due to the slowness of I2C communication. This would have been fine, but the ADXL was not sampling during this time period and so we would be losing some data.
Knowing SPI communication is faster than I2C we switched to that and sure enough it now only take a few hundred microseconds to transfer all 25 registers. The problem is now the data rate is not 25Hz. Instead of sampling at 40ms it is sampling at close to 41ms. It is consistently sampling at this rate, but is not the desired 25Hz. In I2C the sampling rate works great. Why would it change in SPI? Is there something I can do to fix this or is this expected for some reason?
May I know what mode of read you used in popping the fifo data?
If a single-byte read operation is performed, the remaining bytes of data for the current FIFO sample are lost. Therefore, all axes of interest should be read in a burst (or multiple-byte) read operation. To ensure that the FIFO has completely popped.
For 40mS vs 41mS interval of sampling, are you using the int1 interrupt of the adxl345? the cause might be the time required for the Arduino to service the ISR.
Hope this help
Sorry for the late response. I am reading the fifo data in burst read operation.
I am not using the interrupt on either I2C or SPI. I am reading the FIFO_STATUS register in my main loop to see when there are 25 readings, and then reading in those readings immediately. There is no structure change in either of my programs besides switching to SPI.
As a side note I have noticed that while transferring data between the Arduino and ADXL345 the ADXL stops sampling and won't start until I am done transferring data. Is this normal?