cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2HH12 with DMA

Alexandre T
Associate II
Posted on November 03, 2017 at 09:55

Hello,

I implemented a DMA with my LIS2HH12 to avoid losing datas.

The problem is that my DMA is too fast, I am able to read at 1.8kHz (1800 (x,y,z) datas in 1 second) thanks to my DMA but the max ODR that I can choose on my accelerometer is 800Hz.

So I am wasting a lot of memory with my DMA cause if I choose a 400Hz ODR if have a new data available each 4 or 5 sample.

As I understood, it is not possible to change the DMA speep. Did I miss something on the datasheet that could help me to solve my problem ? 

FIFO is interesting but while reading all the registers to get (x,y,z) datas, I will loose some datas ?

Note : I don't want an interrupt when new data available cause it will stop my program everytime
1 ACCEPTED SOLUTION

Accepted Solutions
Miroslav BATEK
ST Employee
Posted on November 05, 2017 at 21:40

I think the best solution is to use FIFO and read the data in bursts. You can configure INT1 to generate an interrupt if FIFO reach a certain level and then read all the data in FIFO using DMA. This approach will reduce number of interrupts and avoid any data loss.

View solution in original post

8 REPLIES 8
Miroslav BATEK
ST Employee
Posted on November 05, 2017 at 21:40

I think the best solution is to use FIFO and read the data in bursts. You can configure INT1 to generate an interrupt if FIFO reach a certain level and then read all the data in FIFO using DMA. This approach will reduce number of interrupts and avoid any data loss.

Posted on November 06, 2017 at 09:23

I imagined an other solution using a timer and the DMA TC interrupt. I'll try both

Posted on November 06, 2017 at 16:57

I am currently trying to implement your solution but I don't really understand the 5.3.3 chapter in the datasheet. If I want to have 20 values available when the interrupt occurs. What should I put in FIFO_CTRL(FTH4:0) and how many samples I need to read ? 

Posted on November 08, 2017 at 13:42

My understanding is 

if the watermark is set for example to 20, you should read 21 samples each time the interrupt occurs but only after first interrupt all samples are valid, then you should discard first sample because it is equal to last sample from previous batch.

I'm currently checking this with sensor specialist and I will come back to you as soon as possible.

You can also check the

http://www.st.com/content/ccc/resource/technical/document/application_note/60/52/bd/69/28/f4/48/2b/DM00165265.pdf/files/DM00165265.pdf/jcr:content/translations/en.DM00165265.pdf

.
Posted on November 08, 2017 at 13:49

Yes, I already checked the AN.

Thank you for your help, I'll wait his answer !
Posted on November 10, 2017 at 17:55

Any news

Batek.Miroslav

‌ ?

Posted on November 17, 2017 at 14:34

I got an answer from the sensor specialist. My understanding was correct, but they proposed me another approach: 

If you want to have 20 values available when the interrupt occurs you should set 20 (14h) into FIFO_CTRL(FTH4:0) and read 20 samples each time the interrupt is triggered. The interrupt will be actually triggered when the FIFO reach 21 sample and one sample will always remain in the FIFO, but in this case you don't have to discard any sample. 

Posted on November 22, 2017 at 09:05

Actually, I put the FIFO depth to 19 and I read 20 samples. It works because during DMA buffer filling, new samples are available, so I can read at least one more sample.

Thank you for your help, I now clearly understand this part of the datasheet and it may help other people !