cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 ADC DMA without Interrupt

benjamin Gräf
Associate II
Posted on June 01, 2018 at 10:47

Hello!

Is it possible to use the ADC in DMA mode without enabling the interrupt? I really do not need the interrupt because it will block the rest of my programm, which is very important to not be blocked. The ADC runs very fast and therfore many interrupts occur. The DMA writes the value of the ADC into a variable in the RAM storage. So why use an interrupt, I just read the value in my main programm. 

I am using CubeMX for configuration.

best regards,

Benjamin.

#stm32-adc-dma
4 REPLIES 4
stm322399
Senior
Posted on June 01, 2018 at 11:48

Of course you can. When using DMA, there are few reasons to enable ADC interrupts.

On the other side, DMA interrupt might be required to collect a batch of conversions.

It is even possible to let ADC + DMA to convert data and store into a circular buffer, and use no interrupt at all. In that case, you are required to collect data by polling (fast enough not to overrun!), which is possible because the DMA can tell you where in the buffer it is ready to write the next conversion (reading length register).

Are these scenarii easy to configure with CubeMX ... don't know

:(

Posted on June 05, 2018 at 08:45

Thank you for our answere!

You said:

'

It is even possible to let ADC + DMA to convert data and store into a circular buffer, and use no interrupt at all. In that case, you are required to collect data by polling (fast enough not to overrun!), which is possible because the DMA can tell you where in the buffer it is ready to write the next conversion (reading length register).'

Why do  I need to poll? Is it not possible to just read the Variable the DMA is constantly writing to? The value stored there should match the latest measured value, or am I missing something here?

Best regards, Benjamin.

Posted on June 05, 2018 at 09:38

Why do  I need to poll? Is it not possible to just read the Variable the DMA is constantly writing to?

This IS polling.

The value stored there should match the latest measured value, or am I missing something here?

You don't know know how 'old' this value is, the lates one might be nanoseconds away...

The SPL code contained a lot of ADC examples working that way: continuous single-channel conversion with DMA, and no interrupts. The main code read the value at arbitrary times.

This is quite a non-realistic use case, though. Usually, you have either more than one channel, or you are interested in the sequence (equidistant samples). In this case, the DMA TC interrupt serves as 'reference point'.

Posted on June 06, 2018 at 11:02

OK, thank you.

Well I will find a way which will work for me