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.

Question about EDMA!

Hello! I have a question, in fact a doubt. I' am developing an aplication based on the dsk_app exemple(bsl/dsk_app) . In order to allocate dinamic memory i have modified the application so that i am no longer using edmaHwi as an interrupt   neither processbuffer as a SWI. I have something like this :

 

while(1){

    static Uint32 pingOrPong = PING;  // Ping-pong state variable
    static Int16 xmtdone = 0, rcvdone = 0;
 
    /* Check CIPR to see which transfer completed */

    if (EDMA_intTest(gXmtChan))
    {
        EDMA_intClear(gXmtChan);
        xmtdone = 1;
    }

    if (EDMA_intTest(gRcvChan))
    {
        EDMA_intClear(gRcvChan);
        rcvdone = 1;
    }

    /* If both transfers complete, signal processBufferSwi to handle */
    if (xmtdone && rcvdone)
    {
        if (pingOrPong==PING)
        {
          
          // nrFrame= proceseaza_intrare(EC,gBufferRcvPing,BUFFSIZE,&caracteristici);
         //  LOG_printf(&trace,"%d",nrFrame);
        
           copyData(gBufferRcvPing, gBufferXmtPing, BUFFSIZE);
 
            pingOrPong = PONG;

        }
          else
        { 

           //nrFrame= proceseaza_intrare(EC,gBufferRcvPing,BUFFSIZE,&caracteristici);
           LOG_printf(&trace,"%d",nrFrame);
          
           copyData(gBufferRcvPong, gBufferXmtPong, BUFFSIZE);
           pingOrPong = PING;
          
           rcvdone = 0;
           xmtdone = 0;
          
         }

Now, the question is: could i lose some samples? Is this ok ? Thank you very much!

  • It is possible since you depend on the CPU finishing copyData() before the EDMA finishes its next block transfer.  The function copyData() should not take more time than the EDMA takes to transfer the ping (or pong) buffers. I should say though you have the same restriction/risk applies to the approach using HWIs and SWIs.

  • Hello! Thank you. I also do a lot of sound processing before calling copyData, i mean windowing, fft, magnitude spectrum...getting 13 feature components and first and second derivative. So, you suggest that it is a risk to apply din method? I am trying very hard to optimize the  code to be real time. have any sugestions?

  • You'll have to profile your code to figure out if you are meeting the deadlines.  However, think about this: on top of all the processing you want the DSP to do you also want it to transfer data.  My recommendation would be to leave the data transfer to the experts: the EDMA.  =)

  • Stefan,

    Which DSP are you using?

    There is not enough code in your snippet to offer an accurate appraisal of your code performance. For example, if there is no task switch or SEM_pend() in the while(1) loop, you might as well comment out the second LOG_printf() because you will never be in the IDL code to transmit anything. And if you have a very linear process flow with your audio manipulation hidden behind the comments, then you should be able to accurately measure how much time the processing takes and the copyData and the time between CIPR bits being set.

    Stefan George said:
    a risk to apply din method? I am trying very hard to optimize the code to be real time.

    What is "din method"?

    Why did the use of dynamic memory prevent you from using EDMA? You can configure the EDMA PARAM with whatever SRC & DST addresses you want, and that should have no bearing on the use of the edmaHwi interrupt dispatcher. This confuses me about your situation.

    A simple QDMA call can do the copyData very easily and will do it faster than the DSP code, at least it will if it is setup ahead of time and you just write src/cnt/dst.

    Are you trying to optimize the code within the compiler tools, or by your program architecture, or by the system design?

    Compiler tools: Study the C Compiler User's Guide and look to the Wiki pages for guidance. There are a lot of optimization tools that do a magnificent job.

    Program architecture: If your sound processing is reading the rcv samples and generating xmt results back into the rcv buffer, consider writing the xmt results directly to the xmt ping/pong buffer rather than overwriting the rcv buffer and then copying it to the xmt buffer. This would save the copyData step completely. And measure the time for the major components so you can answer the question yourself about whether you are at risk of losing data.

    System design: Do not use the CPU for data movement. Use EDMA/QDMA/IDMA, but make sure as much as possible is setup ahead of time; do not try to take our functional examples and assume they are optimized for your purposes. Make things happen in parallel.

     

  •      First of all...i am using c6713. The second issue :"Why did the use of dynamic memory prevent you from using EDMA?" - EDMA did not prevent me for using dynamic memory, but the HWI and SWI. I've read that i not correct to you use MEM_alloc in a HWI/SWI so i am doing MEM_alloc in main. Those commented lines are the function that do the sound processing. I try to optimise the code using all 3 methods that you've pointed. Thank you very much!

     

     

  • Best of success to you. A couple of my comments do not apply to the EDMA in the C6713, such as QDMA writing (even easier to use in C6713 than in EDMA3) and IDMA (does not exist in C6713).

    If you have the option to move to a newer DSP, like the C6747 or C6748, you might find some performance improvements. But if the C6713 is what you have available, then I hope it will serve you well, too.

  • No, i am afraid that c6713 is my only option. Anyway...i've taken your advice and removed the copyData function. Thank you very much for the answers! Best regards, George!

  • As Gus says in his footer, if your question has been answered, please indicate so by marking the appropriate posting as a Verified Answer.

    A common DSP/BIOS program architecture is to use Tasks for the control code that allocates memory and directs the sound processing, and then limit the HWI to simply clearing interrupts and setting semaphores. Some people will post SWIs from a TSK to do the primary sound processing, just to avoid the task switching that might occur when multiple task priorities are used.

    But it does sound like you are well on the way to completing your project. So best of success to you!

    And please consider sharing lessons-learned either by posts to the forum or by writing a Wiki topic. The Community stays strong when others can build on your successes.