Showing results for 
Search instead for 
Did you mean: 

DMA write single ADC value incrementally into buffer


I want to make it so the DMA continuously writes the value of an ADC channel into a large buffer in a way that it doesn't write over the previous value in the buffer, but it increments the address so it fills the buffer with values from that singular ADC channel. How can I do this? I want to buffer the ADC readings first without doing anything in between so I can get a large number of readings from a small duration of time and process them later to split up the CPU loading.

Also I need the one ADC channel to be the only one that gets scanned at this time out of four configured ADC channels. How?


Which STM32? ADCs in them differ significantly.

Generally, if you configure ADC for a sequence length 1, then starting repeated conversions (either through continuous mode or using an external trigger e.g. timer) converts that one channel; and DMA appropriately configured for ADC in turn transfers the conversion results into memory.

Read DMA and ADC chapters in Reference Manual.


STM32WB55CG. As I wrote, I want to scan one channel and have the value of that incrementally written into a buffer. The way you just described makes it circle back to the start of the buffer and just continously rewrite that one value. I want it to fill the buffer.

I read DMA and ADC chapters in Reference Manual before posting.

> The way you just described makes it circle back to the start of the buffer and just continously rewrite that one value.

Not, if you set DMA's NDTR to a value bigger than 1, and if you set memory address increment in DMA.


If I increase the NDTR wouldn't the ADC sample the other configured channels which are lower in rank than the channel I wish to use or does the fact that 'Increment address' is not selected on the Peripheral make it stay in the first channel?

That you use the word "rank" it indicates that you attempt to get this working by clicking in CubeMX - Reference Manual does not use that word.

Read the Reference Manual, ADC chapter, to understand, how ADC sequences work. Select sequence length 1, and then only one channel gets converted again and again (the first "rank").

You never told us which STM32 are you using; ADC in various STM32 families differ significantly; however, there's always some method how to set the sequence length (and then the order of channels within the sequence, that's what CubeMX calls "ranks").

I don't use CubeMX nor Cube/HAL, so can't really help with this more.