This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

uDMAChannelTransferSet() shorter solution?

Hello everyone


So for those who use the DMA must know that after a transfer is done you need to use uDMAChannelTransferSet() to re-enable it again.
Well most of the times I don't need to change most of the parameters, so can I with HWREG() method avoid setting all those parameters?

In the description of the stop mode it says:
"At the end of a transfer, the μDMA controller updates the control word to set the mode to Stop."

So this means that if I simply change the control word to set the mode to Basic (example) then set the reg DMA Channel Enable Set? With this will a transfer occur with every trigger? Of course in real use I would change some more things like the source address or the transfer size.


If someone could help I would appreciate it. This function is way to big for interrupts so I wanted to not only use HWREG method but also avoid unnecessary setups.

  • Hello Luis,

    Yes. You can directly update the SRAM location for the corresponding channel's control word for the control type and transfer size if the source and destination address is the same (for trial purpose).

    SRAM ADDRESS in UDMACTLBASE + (0x10* Channel Number) + 0x8 should be the word.

    Regards
    Amit
  • Thanks for confirmation Amit,

    What I only need to change is the source address, the transfer size and re-enable back to basic mode. Just 1 little difference I guess, just the destination address is unchanged but I had applications where the transfer size was always the same for example.

    Maybe a example for setting up the transfer with HWREG method would be a good thing to add to an application note so users can easily chose which parts to include. This function, at least for me, is used lots of times in interrupts.
    1 interrupt is okay I guess, but I have 8 it would be cool to have an easier implementation (I had to come ask, read the datasheet, read the source code). Just a suggestion, the DMA can be daunting for most users so more info and examples would help them.
  • One trick I've used is to configure the transfer once with uDMAChannelTransferSet, then copy the contents of the .ui32Control field of the appropriate tDMAControlTable entry into the .ui32Spare field of that same entry. Then, in an interrupt somewhere I just copy the contents back with 1 operation and the transfer is all set again.

    And of course using bit-banding to control the channel enable bits is handy as well.

    The DMA indeed has a steep learning curve, but not impossible! (let this act as an encouragement to anyone reading who is afraid to try)

    EDIT: Oh, and another thing: scrap the notion in the manual to use uint8_t[1024] as the datatype for the DMA control table! Use tDMAControlTable[64] instead - that way you get your IDE to "give access" to the named fields more easily and you don't need to to any special arithmetic for channel indexing (just +32 if you want to access the secondary controls).

  • Hi Veikko,

    Yes I noticed that with the controltable XD
    I did have problems with that but I didn't know if I could do what you suggested (was afraid that the Tivaware functions would complain).
    So I just casted it to (uint32_t*) and the buffer pointer to (uint32_t) since it was a uint8_t*. I have sincerely now idea if it's better or worst with this method.

    Since the handlers are very specific only he transfer size and source pointer can change. I have those saved in variables so I can just straight get them in there.

    I always get confused about the concepts, bit-banding and other similar, must be because English is not my language, maybe I learned another name.
    What I did was OR some macros and variables into the control word.
  • Hello Veiko

    Nice Trick with using the spare location.

    Regards
    Amit