cancel
Showing results for 
Search instead for 
Did you mean: 

What's a DMA TransferAllocatedPort?

Brian H
Senior

I'm still working my way around the DMA learning curve.  Having found the IOC approach to DMA configuration too confusing, I'm configuring the structs and calling the HAL_DMA_Init(...) method myself.

Something I haven't been able to find clearly described is the "TransferAllocatedPort" field of the DMA_InitTypeDef struct.  I understand that it's there to specify source/destination port0/port1, but I don't understand the significance of that selection.

One blog post I found seems to say that having two ports allows the DMA peripheral to assemble or disassemble transfers when source and destination have differing alignments.  Okay, I understand that explanation, but is that a correct explanation?

If my source and destination have the same alignment, can (or should) I assign the same port to both?  Is there any advantage or disadvantage?  Since a "channel" is devoted to a particular path and direction, I wouldn't think the unused port would be useful for anything else at the same time.

Put in terms of code, right now I've naively written:

dma_handle.Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0 | DMA_DEST_ALLOCATED_PORT1;

Should I (or should I definitely not) do this instead:

dma_handle.Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0 | DMA_DEST_ALLOCATED_PORT0;
3 REPLIES 3
waclawek.jan
Super User

I'm looking at the  CubeF1 DMA HAL header and can't see any TransferAllocatedPort field.

Generally, Cube/HAL is primarily a vehicle for the CubeMX-based clicking, so anything you can't click there may or may not be hard to use through Cube/HAL. It was never the intention to use it by "programming" the .ioc file.

Also, Cube/HAL is open source, so you can find out by reading it and comparing its actions to reference manual, what is the intention of each init struct field.

JW

waclawek.jan
Super User

Oh, and the resemblance of my avatar and that one in the blog post you refer to above, is not coincidental. However, the 'F1 does NOT have the dual-port DMA - that's the single-port DMA. You are probably using some of the newer families - there are new DMA types there (labeled MDMA, GPDMA, LPDMA by ST), very different from those in the older STM32 families; I don't know these new DMAs as I don't use those families, so read that blog post in that context.

JW

Ah, I tagged incorrectly.  I'm working on several projects at once.  This question is relevant to the H563.  I'll fix the tag if I can.

I always respect a "RTFM" answer.  Thing is, I've R'd the FM (RM0481).  It clearly indicates that SAP and DAP are for choosing the source and destination ports.  It doesn't say much (in a way that I can grok, at least) about whether those two fields have to be different, or what the requirements / ramifications are of the different permutations.

I may have given the wrong impression.  I'm not touching the .ioc, but writing code by hand in a .c file.  Let's pretend I'm not using HAL at all and instead looking at the SAP and DAP bits in CxTR1.

I've naively set SAP = 0 and DAP = 1.  Given that in my application, source and destination alignment is the same and I'm using two FIFO-equipped channels, should I instead (or should I definitely not) set SAP = 0 and DAP = 0?  Or maybe SAP = 1 and DAP = 0?  SAP = 1, DAP = 1?  Are there trade-offs?  Benefits?  The fact that those bits exist implies there are reasons one might want to set them a particular way.  Does it simply come down to arbitration?  The block diagram makes it look like the whole GPDMA instance has Port 0 and Port 1, and those are shared across all transfers and all channels as configured, meaning each individual transfer has to wait its turn for its assigned ports.  Perhaps I can gain some parallelism across channels by setting it differently?  Or, since it's a FIFO channel, the parallelism gains cancel out since the FI and FO have to happen sequentially if SAP and DAP are the same?

This is why I'm asking questions.  I'm trying to understand the information in the reference manual, and would like some advice on whether I'm understanding it correctly.

Note: My current code works and does what I want.  I just want to understand it better.