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.

Memory to McASP transfer using EDMA3 in OMAP 137

Other Parts Discussed in Thread: OMAPL138

Hi,

I am trying to transfer data from the memory to McASP using EDMA3. I have read several posts on this subject but could not figure out the issue. 

For example I use EDAM1 channel 0 for the transfer to McASP1 XBUF0. In my ParamSet I set the source and destination and set the increments correctly. This is the sequence I configuration.

1. Configure the DMA channels as an A-Synchronous TR.

2. Configure the McASP and take the McASP out of reset.

However I can't see any data transfers happen.  I have following questions.

1. How does the McASP know which DMA channel is used for servicing, In other words how does it send the sync event to the correct bit in the ER register? Do we need to do any additional configuration in OMAP 137 (C6747)

2.  What is the correct port address of the McASP XBUF to be used. I see the base address ranges for accessing McASP through DMA is different but could not find too much details). For example data sheet says the base address is 0x1d06000 for McASP1. So can we access XBUF0, XBUF1, ..... XBUF31 with Base address + offset of XBUFn?

3. The only configuration modifications specific to EDMA transfer in McASP side I could find  is setting XBUSEL = 0 in XFMT and XEVTCTL = 0 (which is set to 0 by default). Are there other DMA specific settings?

Thanks a lot for the help in advance.

Shaminda

  • Hi,

    Please refer the below E2E post for a working McASP-EDMA audio loopback sample code available for OMAPL137 platform which is ported from OMAPl138. Kindly use the same as reference example for McASP-EDMA configuration to validate for OMAPL137 platform.

    https://e2e.ti.com/support/dsp/omap_applications_processors/f/42/p/423721/1512249#1512249

    Please use the above sample example code.

    If helpful, kindly refer the below wiki's:

    http://processors.wiki.ti.com/index.php/Getting_Started_Guide_for_OMAP-L137#Purpose

    http://processors.wiki.ti.com/index.php/StarterWare_Audio_Application

    Thanks & regards,
    Sivaraj K

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

  • Thank you very much for your prompt response. It was very helpful.

    Best,

    Shaminda

  • Hi Sivaraj,

    I followed the example code you pointed out and moved it my project. There are some differences in clock dividers and clock direction but I exactly followed the steps of the example. I tried avoiding the example function calls as that needs to bring in a large number of header files that conflict with the set of header files already exist in the project. Here is the extract of the code that enables EDMA channel 3, FIFO and McASP1 for TX using serializer 1. We need to send bit and HF clocks out as opposed the example. I configured the FS and Clock CTL registers appropriately.

    I still do not see the output on the data pins as well as the Data bus register corresponding to McASP1 (0x1d06000) does not get modified by DMA writes. However I do not see any buffer under run in McASP (bit 0 and bit 6 of XSTAT are cleared). FS and CLK signals are coming out from the DMA pins though there is no data output.

    I set the link address in the param set to be 0xffff (only one param set is used and testing only for a single transfer for simplicity) and once the transfer is initialized the A CNT, B CNT ... are changed to 0. Also I see event 3 in ER is set as well. If I understand correctly DMA transfer has completed (as Param set is loaded with 0 after the transfer). What I can't understand is the reason for not see date in the Data bus port (0x1D06000) which actually updates its content with data in your example.

    I believe I captured all the major configuration steps in the following code. Any help on this is highly appreciated.


    /* Function corresponding to EDMA3Init*
    * ------------------------------------------
    * ------------------------------------------
    * ------------------------------------------
    * /


    /* clear the Event missed register*/
    edma3ccRegs->EMCR = 0xFFFFFFFF;
    edma3ccRegs->EMCRH = 0xFFFFFFFF;
    edma3ccRegs->QEMCR = 0xFFFFFFFF;
    edma3ccRegs->ECR = 0xFFFFFFFF;
    edma3ccRegs->EECR = 0xFFFFFFFF;

    /*Clear CCERR register */
    edma3ccRegs->CCERRCLR = 0xFFFFFFFF;


    /* For EDMA enable DMA 0-64 channels in the DARE regions
    *
    */
    edma3ccRegs->CCERRCLR = 0xFFFFFFFF;

    /*Enable DMA shadow regions
    *
    * */

    edma3ccRegs->DRA[1].DRAE = 0xFFFFFFFF;
    edma3ccRegs->DRA[1].DRAEH = 0xFFFFFFFF;


    /* Initilize DMA queue number registers
    *
    * */
    int queue_num = 0;
    int i;
    for (i = 0; i< 32; i++)
    {
    edma3ccRegs->DMAQNUM[i>>3] &= ~(0x7 << ( (i % 8u)*4u ));
    edma3ccRegs->DMAQNUM[i>>3] |= (0x7 & queue_num) << ( (i % 8u)*4u );
    }

    /* Initilize QDAM queue number registers
    *
    * */

    edma3ccRegs->QRAE[1] = 0xFFFFFFFF;
    for (i = 0; i< 8; i++)
    {
    edma3ccRegs->QDMAQNUM &= ~(0x7 << ( i*4u ));
    edma3ccRegs->QDMAQNUM |= (0x7 & queue_num) << ( i*4u );
    }



    /* Enable DMA channel 3 for McASP1 TX
    * ----------------------------------------------
    * ---------------------------------------------
    * */

    int qnum = 0;
    edma3ccRegs->DRA[1].DRAE |= 0x01u << 3 ; /* For channel 3 */
    edma3ccRegs->DMAQNUM[0] &= ~(0x7 << ( (3u % 8u) * 4u )); ; /* For channel 3 */
    edma3ccRegs->DMAQNUM[0] |= (0x7 & qnum << ( (3u % 8u) * 4u )); /* For channel 3 */

    /* Enable shadow region for channel 3 interrupts
    *
    */
    edma3ccRegs->DRA[1].DRAE |= 0x01u << 3 ; /* For channel 3 */

    /* Enable channel interrupts
    *
    */
    //edma3ccRegs->IESR |= 0x01u << 3; /* For channel 3 */

    /*Enable Event interrupts
    *
    */
    edma3ccRegs->SHADOW[1].IESR |= 0x01u << 3 ; /* For channel 3 */



    /* Set Channel 1 Param Set
    *
    *
    */
    edma3ccRegs->PARAMSET[3].OPT = 0;
    edma3ccRegs->PARAMSET[3].OPT &= ~(0x0003F000u);
    //edma3ccRegs->PARAMSET[1].OPT |= ((((0x0003F000u) >> (0x0000000Cu)) & (1)) << (0x0000000Cu));

    edma3ccRegs->PARAMSET[3].OPT |= 0x2 << 8 | 0x2; /* 32 bit words No chaning is done. Interrupts are disabled,
    A sync transfer, FWID = 16bits */

    // Initialize EDMA Event Src and Dst Addresses
    edma3ccRegs->PARAMSET[3].SRC = (Uint32)&Audio;
    edma3ccRegs->PARAMSET[3].DST = (Uint32)0x01D06000;

    // Set EDMA Event PaRAM A,B,C CNT
    edma3ccRegs->PARAMSET[3].A_B_CNT = 0x00400004;
    edma3ccRegs->PARAMSET[3].CCNT = 0x00000001; /* i*/


    // Set EDMA Event PaRAM SRC/DST BIDX
    edma3ccRegs->PARAMSET[3].SRC_DST_BIDX = 0x0000004; /* no jumps in the address updates */

    // Set EDMA Event PaRAM SRC/DST CIDX
    edma3ccRegs->PARAMSET[3].SRC_DST_CIDX = 0x00000000;


    // Set EDMA Event PaRAM LINK and BCNTRLD
    edma3ccRegs->PARAMSET[3].LINK_BCNTRLD = 0x0000ffff; // This the last transfer. No linking is done.

    /* Now configure the McASP
    * -----------------------------------------------------------
    * -----------------------------------------------------------
    */

    /* Reset McASP1
    *
    */
    mcasp->regs->XGBLCTL = 0x00;
    int num_ser =1;
    int words_per_ser = 1;

    /* FIFO Enable */
    WFIFOCTL_MCASP1 = ( num_ser | (( num_ser * words_per_ser) <<(8u)) );
    WFIFOCTL_MCASP1 |= 0x00010000u; /* enable FIFO */



    /* Configure MCASP 1
    *
    */

    mcasp->regs->XMASK = 0xffffffff; // No padding used
    mcasp->regs->XFMT = 0x00008070; // MSB 16bit, 0-delay, no pad, CFGBus
    mcasp->regs->AFSXCTL = 0x00000112; // 2TDM, 1bit Rising edge INTERNAL FS, word
    mcasp->regs->ACLKXCTL = 0x000000AF; // ASYNC, Rising INTERNAL CLK, div-by-16
    mcasp->regs->XCLKCHK = 0x00FF0008; // 255-MAX 0-MIN, div-by-256
    mcasp->regs->XTDM = 0x00000003; // Slots 0,1
    mcasp->regs->SRCTL1 = 0x000D; // MCASP1.AXR1[1] Transmits to --> peripheral


    mcasp->regs->PFUNC = 0; // Pins are all MCASP, none are GPIO
    mcasp->regs->PDIR = 0xfe00ffff; // All data pins, AXR1[0-15] are outputs, as are ACLKX1 and AFSX1.
    mcasp->regs->XINTCTL = 0x0F; // Not used


    /* Follow the exact procedure to enabel DMA for TX
    *
    *
    */

    /*McASP tx enable
    *
    */
    mcasp->regs->XGBLCTL |= 0x800u; /* release state machine */
    while (mcasp->regs->XGBLCTL & 0x800u != 0x800u);

    mcasp->regs->XGBLCTL |= 0x1000u; /* release Frame Sync Generator */
    while (mcasp->regs->XGBLCTL & 0x1000u != 0x1000u);

    /* reset High frequency clock */
    mcasp->regs->XGBLCTL |= 0x200u; /* release state machine */
    while (mcasp->regs->XGBLCTL & 0x200u != 0x200u);

    /* enabel bit clock */
    mcasp->regs->XGBLCTL |= 0x100u; /* release state machine */
    while (mcasp->regs->XGBLCTL & 0x100u != 0x100u);


    /* Enable DMA event */

    edma3ccRegs->SHADOW[1].SECR = 0x01u << 3 ; /* For channel 1 */
    edma3ccRegs->EMCR |= 0x01u << 3 ; /* For channel 1 */
    edma3ccRegs->SHADOW[1].EESR |= 0x01u << 3 ; /* For channel 1 */


    /* Enable Serializers */
    mcasp->regs->XSTAT = 0xFFFF;


    mcasp->regs->XGBLCTL |= 0x400u; /* release serializers */
    while (mcasp->regs->XGBLCTL & 0x400u != 0x400u);

    /* wait while XDATA is cleared */
    while (mcasp->regs->XSTAT & 0x20u );



    /* Enable McASP */
    mcasp->regs->XGBLCTL |= 0x800u; /* release state machine */
    while (mcasp->regs->XGBLCTL & 0x800u != 0x800u);

    mcasp->regs->XGBLCTL |= 0x1000u; /* release Frame Sync Generator */
    while (mcasp->regs->XGBLCTL & 0x1000u != 0x1000u);

  • Hi,

    The shared McASP-EDMA audio loopback sample code for OMAPL137 is being tested at our end on DA830 DSK board which is OMAPL137 and we heard audio output on LINEOUT without any issues.

    OMAPL137 Is a DSP wake up device and it will be automatically comes out of reset when you try launching debugger to connect to the target.

    Kindly test the example "as-is" since it is working from my end.

    Thanks & regards,
    Sivaraj K
  • Hi Sivaraj,

    Yes, I agree. I have tested the example as-is and audio comes out. However there are some differences in our setup. For example the clock directions are different and we used different clock rates. However I don't think that is the reason for the issue. 

    Also you will understand TI has a number of different header files and macro definition files for different examples and once we combine some of them there are number of conflicts.  But to be fair I combined your example with our project and  spent a quite a bit of time to resolve the conflicts that occurred with ethernet CSL libraries. Even with that effort we could not see any audio output. I really think there is some non-obvious configuration issue which has not been triggered in your example is the reason for our issue.

    That is the reason I created a simple sequence of operations based on your example summarizing all the steps related to EDMA and McASP programming. We do expect TI  to provide some guidance to troubleshoot based on the provided code and stand by their product. I do appreciate providing an example but expect TI will provide support beyond giving an example as each individual need is different from a generic example. 

    Best,

    Shaminda

  • Hi,

    Actually the EDMA and McASP configuration is basically taken from OMAPL138 platform which is a TI's officially released basic McASP-EDMA example configuration and only porting efforts on OMAPL137 would require only SoC and platform level changes. So, I don't think, the shared example shouldn't mess up with McASP and EDMA configuration for sure.

    But anyway, we would take up your point in providing support beyond providing examples and we really appreciate for your valuable feedback and inputs shared which would help other E2E community members too.

    Thanks again for your inputs.

    Regards,
    Sivaraj K
  • Hi Sivaraj,

    Thanks for you response.  I really appreciate if you could have a look at the configuration in my previous request and point to the correct direction for debugging.

    Best regards,

    Shaminda