cancel
Showing results for 
Search instead for 
Did you mean: 

STm32G431: Advice on how to continuously scan (regular) ADC input channels and place results in memory?

Mike xx
Associate III

I assume I would use DMA and have gone some way to (unsuccessfully) sample values in 4 channels in ADC1 and 3 channels in ADC2. However all the sample values seem unchanging for each ADC and obviously don't contain data for all the channels.

I can't find a ADC-DMA example in the corresponding Firmware (STM32Cube_FW_G4) projects directories and wondered if there was an example project that might go some way to assist.

I'm very aware that I could read several hundred pages but I value a few words from anyone who can point me in the right direction.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

This one does ADC DMA:

https://github.com/STMicroelectronics/STM32CubeG4/blob/3e5243a22addb3cd323dba491eaf43c85ff448f3/Projects/NUCLEO-G431RB/Examples/ADC/ADC_OffsetCompensation/Src/main.c

You could also go off of an example from another family, such as the F4. They aren't too different.

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

View solution in original post

4 REPLIES 4
TDK
Guru

This one does ADC DMA:

https://github.com/STMicroelectronics/STM32CubeG4/blob/3e5243a22addb3cd323dba491eaf43c85ff448f3/Projects/NUCLEO-G431RB/Examples/ADC/ADC_OffsetCompensation/Src/main.c

You could also go off of an example from another family, such as the F4. They aren't too different.

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

Reading the hundreds of pages is not that hard - in fact, you pay attention to the first few and then quickly skim through those chapters which are obviously unrelated. It's much like reading Victor Hugo - the pages describing lengthily streets and features of medieval Paris aren't that much entertaining, are they. I personally find reading the registers' description especially enlightening.

Polling implementation works?

JW

Mike xx
Associate III

TDK: Many thanks. I am new to the G series and so appreciate any assistance. I've done a lot of work with the F103 which uses streams rather than channels. The ADC is a different beast too.

waclawek.jan: That's not very helpful when all I wanted was a steer. It's not obvious how the DMA can inrement through the ADC channels or run in contionuous mode with the help of DMA. I can only assume from your post that you don't know either.

> It's not obvious how the DMA can increment through the ADC channels

DMA increments nothing. DMA does not care at all what's at the addresses it picks from or stores to. It's the ADC itself which increments through the channels. This can be most easily observed while manually triggering the ADC and polling - or just simply observing its registers in the debugger. No DMA needed at this point.

Next step is to have still manually triggered ADC, but tied to DMA (through DMAMUX - that's the real difference to 'F103 as DMA itself is the same); observing DMA registers (I don't recommend observing ADC registers beyond this point while the process is running, as it may be intrusive) and the target memory.

Then follows timer-triggered not-continuous ADC, then the continuous case.

JW