2 Replies Latest reply on Sep 7, 2017 12:04 AM by RaAl_264636

    Best way to change DMA source?




      I've a question about DMA handling. I want to feed data from SRAM into a control register. This works with a single DMA channel and transaction descriptor. Now, I want to change it to have the possibility to select between multiple (at least 4 to 8) SRAM sources.


      From the WaveDAC component as example, I see that two DMA channels and transaction descriptors are used. I wonder if I have to use N DMA channels and/or TD's or if there's an easier way. 'AN84810 - Advanced DMA topics' states that it's possible to dynamically change a transaction descriptor by another TD. However, this approach seems to need two TD's chained, the modifying TD is always executed, and the data transferring TD is triggered by the modifying TD.


      In my case, the data transfer should be executed always (TD loop configuration). If a change of the source is needed, the new source should be used when the TD starts again. Now, the question is: what's the best way to achieve this without creating multiple DMA components and/or TD's?


      From my understanding of the DMA, it should be possible to reconfigure the source address by calling CyDmaTdSetAddress(uint8 tdHandle, uint16 source, uint16 destination) again with a new source address. If modify the source address between the DMA start signal and before the TD ends, the modification should take effect on the next cycle, right? Do I have to remove the 'preserve TD configuration' temporarily for that?


      Alternatively, should I setup a second DMA which targets the first DMA TD source address? Are there any pros or cons between those approaches? Or is there a better way to achieve this?