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.

EDMA-MCASP ping-pong buffer read problems!

Other Parts Discussed in Thread: TMS320C6748, OMAPL138

Hi


I am still battling with my old foe the EDMA.! Really this is one complex animal and would be good to have a plugin or utility in CCS to configure the edma.

Aside from this, my immediate problem is as follows:

1. I have set up the edma to service the McAsp A/D and D/A. There is only one stereo channel. Both edma channels are ping-pong buffered. One set for Tx and one set for RX.

2. The edma writes to the McAsp works as expected (after solving buffer issues - see earlier posts)

3. Now I have looped back the TX into the RX externally and hope to see the waveform coming out of the TX in the RX buf, which I do.

4. However if I was to read the edma RX buffer in the foreground the buffer gets locked out to further filling by the edma.

5. I have made sure that when the Ping is being read out by the foreground, the pong is getting filled by the edma

6. If I don't do the reads in the foreground the ping-pong buffers get filled properly and I can see that through the mem browser and the memory plots.

7. If I were to read any part of the ping pong buffer, even a single address it gets blocked out for further filing by the edma

This is very strange behavior. Please I am awaiting advice to solve this....

Manjula

  • Hi,

    Thanks for your post.

    Kindly provide the TI device to which you are working into? Which TI board? EVM or LCDK?

    Is it your own code or TI provided example code? If TI provided, which software package you are referrring to? Is it starteware or CSL or BIOSPSP/MCSDK?

    Kindly provide all the above details and other information whichever you think it is appropriate to address your query.

    If possible, please post snapshots for any error it posts which would provide more visibility to the issue.

    Thanks for your understanding.

    Thanks & regards,
    Sivaraj K
  • Hi,

    I presume that it is c64x device and provided suggestions below:

    As you know, the purpose of the ping-pong buffer is to allow you to continue filling one buffer while the other buffer is being DMA'd to the McASP for transmission to the codec output. To my opinion, for a sync'd ping/pong transfer,

    We need 6 PaRAM SETs and two of which are active channels  (one for RCV and one for XMT). The RCV side uses the McASP RBUF as the source and gBufferRcv as the destination. The XMT side uses gBufferXmt as the source and the McASP XBUF register as its destination. The other 4 PaRAM SETs are used for linking ping and pong. The active channels are set as "ping" and are linked to  the pong reload PaRAM SETs. The pong reload PaRAM SET is linked back to ping. Hence, we need two active channels and 4 reload PaRAMSETs which is my understanding.

    I do think, the essential part is that the McASP requires a constant, uninterrupted stream of data in order to prevent underflow of it's XRBUF. Therefore, the ping and pong buffers must remain in sync from the start of the program or else it will lead to underrun issue. Therefore, you must service the EDMA callback interrupt each and every time it happens or it will underrun. Therefore, if you do service the interrupt you will always remain in sync with the ping-pong swap. This means the McASP is essentially pulling the data from the ping-pong buffer whenever it needs, instead of you pushing the data into the ping-pong buffer when it is available.

    Alternative, i would also recommend you to walkthrough the "edma_ping_pong_xfer_reg5" csl example from c6474_CSL_Rel_03_03_01 package which you could download from the link below:

    http://www.ti.com/tool/sprc975

    After you install, you could see the edma ping pong example from the below project path which would be a good starting point to refer edma ping pong buffer example for c64x device:

    ~\ti\c6474_CSL_Rel_03_03_01\C6474\csl_c6474\example\edma\edma_ping_pong_xfer_reg5\build\Edma_ping_pong_xfer_reg5.pjt

    You could execute the above example and walkthrough the code for the edma ping pong buffer functionality.

    Thanks & regards,

    Sivaraj K

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

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

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

  • Hi Sivaraj

    Thank you very much for the reply and information. I have implemented the ping-pong buffering as you have explained. The xmit side ping-pong buffering is working properly and I have verified with a scope. I am having problems with the receive side. I am still investigating and I think there might be a problem with rx side of the McAsp. I am using the LCDK TMS320c6748 board. On this board the McAsp rx is a slave to the TX clocks. There could be a problem of the RX side generating events correctly to the EDMA. This is what I am looking at at the moment.

    Have you got a verified example of ping-pong buffering with EDMA and the McAsp for the LCDK C6748 eval board? This would help a lot.


    Thank you very much for your attention. I will get back to this thread after I have completed my investigation into the McASP.


    Best regards

    Manjula

  • Hi,

    Thanks for your update.

    The same C6748 starterware example code is modified with two buffers (ping, pong) on both tx. and rx. side and accordingly, configure ping pong buffers for 150 stereo samples of 16 or 32 bits/sample. Buffers used in the code are rxbuf_ping, rxbuf_pong, txbuf_ping, txbuf_pong and please check the attched "OMAPL138_StarterWare_McASP_EDMA_PING_PONG.zip" below

    /cfs-file/__key/communityserver-discussions-components-files/791/5618.OMAPL138_5F00_StarterWare_5F00_McASP_5F00_EDMA_5F00_PING_5F00_PONG.zip

    After extracting the above zip file, you could see the McASP play back example project with EDMA ping ping buffers at the below build path:

    ~\ti\OMAPL138_StarterWare_McASP_EDMA_PING_PONG\build\c674x\cgt_ccs\omapl138\lcdkOMAPL138\mcasp\.ccsproject

    Thanks & regards,

    Sivaraj K

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

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

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

  • HI Sivaraj

    This is most probably a Cache problem as the buffers are external to the processor in DDR. So there seems to be a cache coherence problem that I am trying to fix. It would be helpful if you can point me to some code that uses double buffering in external memory and dma that uses the cache coherence calls to manage these types of issues.

    Will let you know if I am able to fix this. So for the cash invalidate calls have failed :( This processor is really complex and I am not sure if I can make the deadlines of the project. There seems to be a gotcha around every corner. I am considering using an arm processor with floating point DSP module (M4) which will be simpler to program and manage.


    For now I haven't still given up. Fingers crossed.


    Thanks and regards


    Manjula

  • Hi Sivaraj

    Ok solved the problem. I allocated the buffers in L2 Ram (after reading another ton of docs on how to do this :))and everything works as expected. So it was indeed the cache coherence problem. I wonder how many other newbies get caught out with this. If you remember my earlier posts I had problems writing out the transmit stream via edma to McAsp. I never got a proper answer for this from TI. Now I know for sure that this was also caused by the coherence problem. It was funny at the time that I had to align the buffers to 128byte boundary and the problem got solved but really didn't know the reason why.
    (Newbies pls look at the c674x cache manual...it has got very good info on this issue when buffers reside in external memory and you use dma to xfer data).

    I am pressing on with this processor fingers crossed.... :)

    Thanks and regards

    Manjula
  • Hi,

    Thanks for your update.

    Glad that your issue got fixed.

    Thanks & regards,
    Sivaraj K