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.

EDMA3 transpose

Hello!

In sprugs5a I read chapter 3.3 Data Sorting Example and was not able to implement it, because not everything is clear to me, e.g. "the channel can be programmed to be chained to itself".

If somebody have an example of matrix copy and transposing, share it, please.

  • Hi,

    Thanks for your post.

    Usually if any application uses multiple data arrays would require multiple triggered transfer which means, completion of one transfer by EDMA would trigger another transfer on the same channel or different channel. If it is by same channel, it triggers the same DMA channel mapped to events accordingly. I think, there are different modes to trigger the data transfer using EDMA3 Channel controller. They are Event triggered, manual triggered and chain triggered transfer requests. In our case, it is chain triggered transer requests to self and a transfer is triggered upon completion of another transfer on the same channel which is self chain triggered.

    This is the explanation which we could give for the above mentioned statement "the channel can be programmed to be chained to itself",  so, after BCNT elements get sorted, intermediate/final chained data transfer could be used to trigger the same channel again causing the transfer of the next BCNT elements and so on.

    For more info. on chain triggered data transfer through DMA channels, you could refer section 2.4.1.3 in the sprugs5a.pdf as below:

    http://www.ti.com/lit/ug/sprugs5a/sprugs5a.pdf

    Also, check section 2.8 for chaining EDMA channels from the above guide. There are also programming /debug tips and debug check list provided in Appendix A.1 & A.2 and Kindly check the same on the guide.

    I don't think, we do have examples directly for matrix copy and transposing, you have to write your own code.

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question

    -------------------------------------------------------------------------------------------------------

  • OK. Conceptually it is more or less clear what I should do. But how it is done with provided API's?

    1. We get EDMA3 handle

    EDMA3_DRV_Handle hEdma = edma3init(0, &result);

    Of course after each step we check result.

    2. We requesting free channel

    unsigned int tcc  = EDMA3_DRV_TCC_ANY;
    unsigned int chId = EDMA3_DRV_DMA_CHANNEL_ANY;
    
    result = EDMA3_DRV_requestChannel (hEdma, &chId, &tcc, (EDMA3_RM_EventQueue)0, &callback_fxn, NULL);

    Now in chId we got number, for example '2'.

    3. Now we set PaRAM according to 3.3 of sprugs5a.pdf

    EDMA3_DRV_PaRAMRegs paramSet = {0,0,0,0,0,0,0,0,0,0,0,0};
    
    paramSet.srcAddr    = (unsigned int)(src);
    paramSet.destAddr   = (unsigned int)(dst);
    
    paramSet.srcBIdx    = sizeof(short);
    paramSet.destBIdx   = sizeof(short) * INITIAL_MATRIX_HEIGHT;
    paramSet.srcCIdx    = sizeof(short) * INITIAL_MATRIX_WIDTH;
    paramSet.destCIdx   = sizeof(short);
    
    paramSet.aCnt       = sizeof(short);
    paramSet.bCnt       = INITIAL_MATRIX_WIDTH;
    paramSet.cCnt       = INITIAL_MATRIX_HEIGHT;
    
    paramSet.bCntReload = 0;
    
    paramSet.linkAddr   = 0xFFFFu;

    4. Set OPT field of PaRAM according to 3.3 of sprugs5a.pdf

    paramSet.opt |= 1 << 2;
    paramSet.opt |= 1 << 20;
    paramSet.opt |= 1 << 23;
    paramSet.opt |= chId << 12;

    note that I wrote channel number to TCC field

    5. Latch

    result = EDMA3_DRV_setPaRAM(hEdma, chId, &paramSet);

    6. Run

    result = EDMA3_DRV_enableTransfer (hEdma, chId, EDMA3_DRV_TRIG_MODE_MANUAL);

    7. Cleanup

    result = EDMA3_DRV_freeChannel (hEdma, chId);
    result = edma3deinit (0, hEdma);

    This configuration copies exactly 1 line of initial matrix to 1 row of target matrix. And no chaining does happen. In dma_chain_test.c the function EDMA3_DRV_enableTransfer is invoked in cycle several times according to number of frames (i.e. initial matrix lines). But when I try to run it several times I get EDMA3_RM_E_CC_DMA_EVT_MISS in status of callback_fxn.

    Also when I change EDMA3_DRV_TRIG_MODE_MANUAL to EDMA3_DRV_TRIG_MODE_EVENT then EDMA3_DRV_enableTransfer returns EDMA3_DRV_E_INVALID_PARAM.

    What is wrong in this approach?

  • My suggested approach actually works. I just suddenly filled only first row of initial matrix and thought tha DMA not working properly. Now I fill the whole matrix and transpond routine works.
    Important: EDMA3_DRV_enableTransfer is invoked once with EDMA3_DRV_TRIG_MODE_MANUAL. Of course the second call wiil lead to event miss.
    Thanks for your attention.
  • Hi Sam,

    You deserve it.

    Thanks for your valuable suggestion which would really help for other E2E community members.

    We appreciate your proposed strategy.

    Thanks & regards,
    Sivaraj K