DMAMUX experiment on stm32H7 with adc's and Gpio's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-05-10 4:13 AM
In one application I am currently developing I have a single pin for an adc input and an analog external mux(4051) on three pins that changes which of my actual 8 adc's is wired on this pin.I would like to iterate over the 8 different mux values and for every iteration I would like to read the adc value (so in 8 cycles I would read all the physical adcs).
I figured I can do that with dma's to offload my cpu so I want some thought's on how exactly I can achieve it.I have read the DMAMUX entry on the h7 reference manual but I am not really sure what I need from the DMAMUX to do. So what I did was :
- Add a circular dma to the adc to trigger at every conversion .This step was done with the high level drivers of cubeMx and it is quite successful as I can read and print one adc value on my screen.
- Enable the dma event request in the dma panel of cubeMx for the adc's dma (DMA1 stream 0)
- Create a new dma request (DMA_GENERATOR_0) from the cubeMx panel on dma1_stream1 ,this request is Circular ,memory to peripheral ,whole world and on the dma request generator settings I put Request Signal :dma1 stream 0 and request number 1
- Then on my main I created a table with size 8 that was setting the gpios to the binary values 0,1,2,...8 lets name it mux_val table
- on my main I connected the dma with the table with the following lines
LL_DMA_SetDataLength(DMA1, LL_DMA_STREAM_1, 8);
LL_DMA_SetMemoryAddress(DMA1, LL_DMA_STREAM_1, (uint32_t)mux_val);
LL_DMA_SetPeriphAddress(DMA1, LL_DMA_STREAM_1, (uint32_t)&MUX_GPIO_Port->BSRR);
LL_DMA_EnableStream(DMA1, LL_DMA_STREAM_1);
Note that for the dma I used the low level drivers as it seems simpler to me.
I had many issues with this which I overcome related to the accessible parts of memory by the DMA on h7.I even tested a dma request from a timer to update the gpios instead of the adc and it worked fine but it seems that something is missing from my dma configuration with the dma_generator instead of a normal request.
I am not quite sure that this is the way to go so I would like to discuss some alternatives(without hardware modifications). Also I would like an explaination on the differences between the cubemx configurations on DMA request Synchronization Settings and the DMa request generator settings and also what I need to correctly initialize the wiring of DMAMUX.How in general one would connect one dma request with two dma data transfers on an h7 even on the simplest cases ?
P.S I also did a similar question on https://electronics.stackexchange.com/questions/563947/dma-multiplexing-on-an-stm32h7?noredirect=1#comment1473163_563947
- Labels:
-
DMA
-
STM32H7 Series
