2021-06-01 01:10 AM
Hi I am using STM32F407ZET6 Microcontroller and I want to use multiple streams of DMA1. Is it possible to trigger two different streams of the same DMA for transferring data to two different peripherals simulatenously. (Like in Parallel).
In the advanced AHB bus matrix I observe that for each DMA there are only two lines, one for memory and one for peripheral, which suggest to me that at any time at max two streams can perhaps run in parallel and that also if none of the streams are really doing memory<->peripheral transfer. Is this assumption correct? And, is this also correct that to run two streams in parallel through a single DMA they should not be doing memory<->peripheral transfer? what I mean is that by the look of AHB matrix it felt if only Mem to Mem and Periph to Periph transfers are done then probably two streams can run in parallel, but if any one of them does memory<->peripheral transfer then the use of DMA memory and peripheral interface for a single transfer will probably make that NOT possible. Can you shed some light on this?
I would like to request some guidance on this particular topic as i could not find satisfactory information on it... And if it is dependent on the bus bandwidth to transfer streams in parallel then how the bandwidth is divided among multiple channels for a single bus to perform multiple transfer.... Some If there is any such example, i would be thankful. As a reference I have put the AHB matrix below:
2021-06-01 03:01 AM
You can have several streams enabled and even triggered at the same time. The transfers themselves don't happen at the same time of course. The DMA module itself arbitrates - based on priority you set in each streams control register - which of them will perform the transfer on a given port first (the DMA module in 'F4 has two ports, memory and peripheral); and when that transfer for that stream finishes, then the remaining active streams are going through the same arbitration process, etc., until all of them finished their transfers.
Read AN4031.
JW
2021-06-01 03:08 AM
Yes, that I totally understand that triggering multiple streams at the same time is definitely possible. But, I wanted to confirm if more than 1 streams, at least 2, can also transfer in parallel over two different ports (streams). With your answer, it gives an impression that it is not possible. Am I correct.?
2021-06-01 03:18 PM
Imagine a train station with 8 platforms, but only 2 pairs of tracks leaving the station (notice the 2 lines at the bottom of the box representing the DMA unit in the figure you posted above).
So, at any given time, only two trains can go through those two tracks.
JW
2021-06-01 03:33 PM
Sorry, but that still does not clarify my point. There are two lines coming out of each DMA. Now, with your answer it feels as if two streams per DMA can run in parallel. Earlier your answer suggested otherwise ....
So, lets rephrase one simple question:: Is it possibleto run two streams in parallel from a single DMA? Lets say one stream going from Memory to Memory and another Memory to Peripheral independently. Lets say its DMA2 because its peripheral port also has a connection with busses going to SRAMs. First of all, is it possible or not... Yes or No? We come to the explanation later ...
2022-01-29 01:40 PM
I ended in this thread with exact same questions, and then after getting nowhere with application notes and datasheet i just tested it.
the answer yes. you can enable all channels working in parallel on the same DMA.
you cant connect same peripheral to more then one channel, but otherwise, all seems working as expected.
disclaimer. i only tested DMA1 on F407 with different communication protocols(uart/spi) working at rather low speed, but different, and they all seems to transmit data just fine.
2022-01-30 03:25 AM
This may be case of me simply misunderstanding of the question.
That all streams "work in parallel" from a macroscopic point of view (in a much similar manner, as - at a much larger timescale - multiple programs/threads run "in parallel" in multitasking environment), I took for granted and trivial. So I interpreted the question as "could transfers happen exactly at the same time (if triggers happened exactly at the same time)"? to which answer is no - the DMA "executes" simultaneously occuring triggers one after other, in the order of their priority (both set and natural, as outlined in RM).
JW
2022-02-04 02:32 AM
Thanks for the reply. Ok so that is clear with respect to multiple streams of a single DMA, lets say DMA1. Now, if we look at the perspective of 2 different DMA's, lets say DMA1 and DMA2, can they in parallel do their transfers since they are two separate DMAs.? Keeping in mind that they do no overlap in using busses / peripherals etc...
2022-02-04 01:23 PM
without considering some special case scenarios, 2 different DMA can work in a completely independent mode simultaneously. e.g. 1 dma can do continuous ADC acquisition into a circular buffer while the other send datastreem to a display via SPI.
I remember reading something about using FIFO to avoid data collision in case of heavy datastreams, but that would be a special case scenario.
2022-02-04 02:09 PM
> Now, if we look at the perspective of 2 different DMA's, lets say DMA1 and DMA2, can they in parallel do their transfers since they are two separate DMAs.?
> Keeping in mind that they do no overlap in using busses / peripherals etc...
Then yes, but it's a pretty marginal/unpractical case. And there are only very few buses to choose from. And there must be no other busmasters access those buses. I still don't understand, why do you ask.
JW