cancel
Showing results for 
Search instead for 
Did you mean: 

Accelerometer data acquisition timing vs microcontroller read timing

ggob
Associate III

The microcontroller acquires data via SPI communication with the accelerometer. What is the risk if the data update timing of the accelerometer and the data acquisition timing of the microcontroller overlap?

3 REPLIES 3
Federica Bossi
ST Employee

Hi @ggob ,

If the accelerometer updates its output registers at the same time the microcontroller is reading them over SPI, the main risk is that you get an inconsistent sample, not physical damage.

To mitigate this effect you could:

  1. Enable BDU in the accelerometer configuration.
  2. Use the data‑ready interrupt/flag to trigger the SPI read.
  3. Always read all the data registers belonging to one sample in a single burst transfer.
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Vidar
Associate III

The risk is corrupted data, which will result in 0 data or some random numbers. An example would be unprotected memory pools, which are accessed by the MCU and the DMA.

 

What would I do in your position?

 

Build your system with a double buffered DMA with a timer as trigger to fetch the data. Use the callbacks to have an interrupt, when the buffer is half full, zero copy the data into a regular buffer in RAM and then proceed. You will need proper MPU or dedicated cache maintainance, depending on your MCU.

As reward you get a system with minimal overhead, reliable data stream and maximum performance.

TDK
Super User

You need to be more specific. What accelerometer? What does the datasheet say about it?

Chips often have protections against reading out mismatched data.

If you feel a post has answered your question, please click "Accept as Solution".