Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

C6745 Mcasp1 GIO_reclaim hungs up

$
0
0

Hi everyone.

I used the mcasp and EDMA for audio receive and transmit.Here are my source code and some ccs5.2 console  messages:

EDMA driver initialization PASS.

Entry the X3107_Mcasp_Task

 Waiting for CODEC ready.

Waiting for CODEC Operation CODEC have already initialize.

Entry the createStreams function.

Stream_create(inStream) returned status = 0

Stream_create(outStream) returned status = 0

Entry the prime function.

Exit the prime function.

NEXT:Entry the I/O operation.

This is the 0 loop before operation.

This is the 0 loop after operation.

This is the 1 loop before operation.

 

Then it hungs up.....at the second loop.

 

 

#include <xdc/std.h>
#include <stdio.h>
#include <ti/sysbios/io/GIO.h>
#include <ti/sysbios/io/iom.h>
#include <xdc/runtime/Memory.h>
#include <ti/sysbios/heaps/HeapMem.h>
#include <xdc/runtime/IHeap.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/Log.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <include/Mcasp.h>
#include <include/edma3_drv.h>
#include <include/bios6_edma3_drv.h>

/* ========================================================================== */
/*                          IMPORTED VARIABLES                                */
/* ========================================================================== */

extern EDMA3_DRV_Handle hEdma;
extern HeapMem_Handle myHeap;
extern Semaphore_Handle   Sem_Codec_ready;
/* ========================================================================== */
/*                          MACRO DEFINITIONS                                 */
/* ========================================================================== */

/*
 * Buffers placed in external memory are aligned on a 128 bytes boundary.
 * In addition, the buffer should be of a size multiple of 128 bytes for
 * the cache work optimally on the C6x.
 */
#define BUFLEN                  512        /* number of samples in the frame */
#define BUFALIGN                128 /* alignment of buffer for use of L2 cache */


/** Number of serializers configured for record */
#define RX_NUM_SERIALIZER       (2u)
#define TX_NUM_SERIALIZER       (2u)

#define BUFSIZE                 (BUFLEN * sizeof(Ptr))

#define NUM_BUFS                2   /* Num Bufs to be issued and reclaimed */

static GIO_Handle inStream, outStream;

/* Function prototype */
static Void createStreams();
static Void prime();

 

 

Ptr buf[NUM_BUFS * 2];

Mcasp_HwSetupData  mcaspRcvSetup = {
        /* .rmask    = */ 0xFFFFFFFF, /* All the data bits are to be used     */
        /* .rfmt     = */ 0x000180F0, /*
                                       * 1 bit delay from framsync
                                       * MSB first
                                       * No extra bit padding
                                       * Padding bit (ignore)
                                       * slot Size is 32
                                       * Reads from DMA port
                                       * NO rotation
                                       */
        /* .afsrctl  = */ 0x00000111, /* 2-slot TDM (I2S mode) to 32-slot TDM,
                                       * Frame sync is single word
                                       * Falling edge is start of frame       //notify
                                       * externally generated frame sync
                                       */
        /* .rtdm     = */ 0x00000003, /* slot 0 and slot 1 are active (DSP)               */
        /* .rintctl  = */ 0x00000003, /* sync error and overrun error         */
        /* .rstat    = */ 0x000001FF, /* reset any existing status bits       */
        /* .revtctl  = */ 0x00000000, /* DMA request is enabled or disabled   */
        {
             /* .aclkrctl  = */ 0x00000000,
             /* .ahclkrctl = */ 0x00008046,
             /* .rclkchk   = */ 0x00FF0008
        }
} ;

Mcasp_HwSetupData  mcaspXmtSetup = {
        /* .xmask    = */ 0xFFFFFFFF, /* All the data bits are to be used     */
        /* .xfmt     = */ 0x000180F0, /*
                                       * 1 bit delay from framsync
                                       * MSB first
                                       * No extra bit padding
                                       * Padding bit (ignore)
                                       * slot Size is 32
                                       * Reads from DMA port
                                       * NO rotation
                                       */
        /* .afsxctl  = */ 0x00000111, /* 2-slot TDM (I2S mode) to 32-slot TDM,
                                       * Frame sync is single word
                                       * Falling edge is start of frame
                                       * externally generated frame sync
                                       */
        /* .xtdm     = */ 0x00000003, /* slot 0 and slot 1 are active (DSP)      */
        /* .xintctl  = */ 0x00000007, /* sync error,overrun error,clK error   */
        /* .xstat    = */ 0x000001FF, /* reset any existing status bits       */
        /* .xevtctl  = */ 0x00000000, /* DMA request is enabled or disabled   */
        {
             /* .aclkxctl  = */ 0x000000C0,    //0x00000080
             /* .ahclkxctl = */ 0x00008046,         //use internal AHCLKX and AHCLKX.The ACLKR,ACLKX,and two Frame clk are external.
             /* .xclkchk   = */ 0x00FF0008
        },

};


/* McAsp channel parameters                                  */
Mcasp_ChanParams   mcasp_chanparam[2]=
{
    {
        0x0002,                    /* number of serialisers      */
        {Mcasp_SerializerNum_2,Mcasp_SerializerNum_3}, /* serialiser index           */
        &mcaspRcvSetup,
        TRUE,                      /* Is DMA Driven              */
        Mcasp_OpMode_TDM,          /* Mode (TDM/DIT)             */
        Mcasp_WordLength_32,
        NULL,
        0,
        NULL,
        NULL,
        2,                        /* number of TDM channels             */
        Mcasp_BufferFormat_MULTISER_MULTISLOT_SEMI_INTERLEAVED_1,
        TRUE,                     /* Option to enable the Hardware FIFO  */
        TRUE                      //notify
    },
    {
        0x0002,                   /* number of serialisers       */
        {Mcasp_SerializerNum_5,Mcasp_SerializerNum_6},
        &mcaspXmtSetup,
        TRUE,
        Mcasp_OpMode_TDM,
        Mcasp_WordLength_32,      /* word width                  */
        NULL,
        0,
        NULL,
        NULL,
        2,                        /* number of TDM channels      */
        Mcasp_BufferFormat_MULTISER_MULTISLOT_SEMI_INTERLEAVED_1,
        TRUE,                    /* Option to enable the Hardware FIFO  */
        TRUE                      //notify
    }
};

 

/*
 * ======== createStreams ========
 */
static Void  createStreams()
{
 printf("\r\nEntry the createStreams function. \n");
    Error_Block eb;
    GIO_Params ioParams;
 
    mcasp_chanparam[0].edmaHandle = hEdma;
    mcasp_chanparam[1].edmaHandle = hEdma;
   
    Error_init(&eb);
    GIO_Params_init(&ioParams);
   
    ioParams.chanParams =&mcasp_chanparam[0];
    ioParams.model          = GIO_Model_ISSUERECLAIM;

    inStream = GIO_create("/mcasp1", GIO_INPUT, &ioParams, &eb);
    printf( "Stream_create(inStream) returned status = %d\n", Error_getCode(&eb));
    GIO_Params_init(&ioParams);
   
    ioParams.chanParams = &mcasp_chanparam[1];
    ioParams.model        = GIO_Model_ISSUERECLAIM;
     
    outStream = GIO_create("/mcasp1", GIO_OUTPUT, &ioParams, &eb);
    printf( "Stream_create(outStream) returned status = %d\n", Error_getCode(&eb));

}

/*
 * ======== prime ========
 */
static Void prime()
{
 printf("\r\nEntry the prime function. \n");
    Error_Block  eb;
    Int32        count = 0;
    IHeap_Handle  iheap;

    iheap = HeapMem_Handle_to_xdc_runtime_IHeap(myHeap);
    Error_init(&eb);
    /* Allocate buffers for the GIO buffer exchanges                          */
    for(count = 0; count < (NUM_BUFS ); count ++)
    {
        buf[count] = Memory_calloc(iheap, BUFSIZE * RX_NUM_SERIALIZER, BUFALIGN, &eb);
        if(NULL == buf[count])
        {
            printf("\r\nMEM_calloc failed.\n");
        }
    }

    /* Allocate buffers for the SIO buffer exchanges                          */
    for(count = NUM_BUFS; count < (NUM_BUFS * 2); count ++)
    {
        buf[count] = Memory_calloc(iheap, BUFSIZE * TX_NUM_SERIALIZER, BUFALIGN, &eb);
        if(NULL == buf[count])
        {
            printf("\r\nMEM_calloc failed.\n");
        }
    }
   /*Issue the first & second empty buffers to the input stream */

     for(count = NUM_BUFS; count < (NUM_BUFS * 2); count ++)
    {

      if (IOM_PENDING != GIO_issue(outStream, buf[count], BUFSIZE * TX_NUM_SERIALIZER, NULL))
             {
                 printf("\r\nFailed to issue the outStream %d empty buffer to stream\n",count);
             }


    }

 

    for(count = 0; count < NUM_BUFS; count ++)
    {

     if (IOM_PENDING!= GIO_issue(inStream, buf[count], BUFSIZE * RX_NUM_SERIALIZER, NULL))
              {
              printf("\r\nFailed to issue the inStream %d empty buffer to stream\n",count);
           }


    }

 

 


   printf("\r\nExit the prime function. \n");
}

/*
 * ======== echo ========
 * This function copies from the input SIO to the output SIO. You could
 * easily replace the copy function with a signal processing algorithm.
 */
Void X3107_Mcasp_Task(UArg arg1, UArg arg2)
{
 printf("\r\nEntry the X3107_Mcasp_Task \n");
   
 if (Semaphore_getCount(Sem_Codec_ready) == 0)
       {
                   printf("Waiting for CODEC ready.\n");

       }

      Semaphore_pend(Sem_Codec_ready, BIOS_WAIT_FOREVER);


      printf("CODEC have already initialize.\n");

 

 

 

 Ptr rcv  = NULL;
    Ptr xmt  = NULL;
    Int status = IOM_COMPLETED;

    /* Call createStream function to create I/O streams             */
    createStreams();

    /* Call prime function to do priming                        */
    prime();

    /* Forever loop to continously  receviec and transmit audio data       */

    printf("\r\nNEXT:Entry the I/O operation.\n");

    UInt   count=0;
     for (;;)
    {
     printf("\r\nThis is the %d loop before operation.\n",count);
            /* Reclaim full buffer from the input stream                          */
        status = GIO_reclaim(inStream, (Ptr *)&rcv, NULL, NULL);      

       
        /* Reclaim full buffer from the input stream                          */
        if (status != IOM_COMPLETED)
        {
            printf("\r\nError reclaiming full buffer from the input stream\n");
        }

        /* Reclaim empty buffer from the output stream to be reused           */
        status = GIO_reclaim(outStream, (Ptr *)&xmt, NULL, NULL);
        if (status != IOM_COMPLETED)
        {
            printf("\r\nError reclaiming empty buffer from the output stream\n");
        }

        /* copy the receive information to the transmit buffer                */
        memcpy(xmt,rcv,BUFSIZE * RX_NUM_SERIALIZER);

        /* Issue full buffer to the output stream                             */
        status = GIO_issue(outStream, xmt, BUFSIZE * TX_NUM_SERIALIZER, NULL);
        if (status != IOM_PENDING)
        {
            printf("\r\nFailed to issue empty buffer to stream\n");
        }

        /* Issue an empty buffer to the input stream                          */
        status = GIO_issue(inStream, rcv, BUFSIZE * RX_NUM_SERIALIZER, NULL);
        if (status != IOM_PENDING)
        {
            printf("\r\nFailed to issue empty buffer to stream\n");
        }


       printf("\r\nThis is the %d loop after operation.\n",count++);

    }
}

 

When it hungs up .The stats registers value are:

 

 

      here  is a Underrun Flag

 And  some more Problems confusing me are  it  can running yesterday.I don't know how to do with it. Can someone help me !

 

Steven.


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>