2021-05-10 04: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 :
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