I am using the McBSP receiver as a master on the C6748. I have started by using the example code that came with the driver. The problem with the example is that it only issues one buffer, and then cannot keep up with streaming data. If I change the number of buffers to 2, it doesn't run. It should keep looping, but it hangs after going through the loop once. This will run to completion if NUM_BUFS is set to 1.
The channel configuration parameters are like the example, except that the clocks and frame sync are generated internally.
Here's the code
/* ========================================================================== */
/* MACRO DEFINITIONS */
/* ========================================================================== */
#define NUM_BUFS 2
#define BUFALIGN 128 /* align buffers to 128 bytes */
#define BUFSIZE 1024 /* 1K of data transceive */
#define LOOP_COUNT 100
#define DEFAULT_BITPERSAMPLE 8 /* number of bits per slot */
#define NUM_OF_CHANNELS 1 /* Number of slots to be used */
/* ========================================================================== */
/* LOCAL VARIABLES */
/* ========================================================================== */
/* Handles for the TX and RX channels */
static SIO_Handle mcbspInHandle = NULL;
/* array to hold the pointer to the allocated buffers */
Ptr bufIn[NUM_BUFS];
Uint32 pktCountIn = 0;
Void mcbspInputTask(Void)
{
Ptr rcv = NULL;
Uint32 count = 0;
Int32 nmadus1 = 0;
Uint32 i = 0;
Bool fail = FALSE;
// Init EDMA
/* initialize the edma library */
if (IOM_COMPLETED != edma3init())
{
printf( "EDMA intialization failed");
return;
}
else
{
printf( "EDMA intialized");
/* update the edma handle to the channel parameters */
mcbspChanparamIn.edmaHandle = hEdma[0];
}
/* create the streams required for the transactions */
mcbspCreateStreamsIn();
/* prime the driver with packets */
mcbspDriverPrimeIn();
/* reclaim each packet and resubmit for "LOOP_COUNT" number of iteration */
for (count = 0; count < LOOP_COUNT; count++)
{
/* Reclaim FULL buffer from the input stream to be reused */
nmadus1 = SIO_reclaim(mcbspInHandle,(Ptr *)&rcv,NULL);
if (nmadus1 < 0)
{
printf("Error reclaiming empty buffer from the streams");
}
else
{
// Commented out this code so it would keep looping
/* compare the received data */
//for (i = 0; i < BUFSIZE; i++)
{
//if (((Uint8 *)rcv)[i] != (i % 0x100))
{
//printf("Iteration %d",count);
//printf("Data compare failed %x %x",
// (i % 0x100),((Uint8 *)rcv)[i]);
//fail = TRUE;
//break;
}
}
// if (TRUE == fail)
// {
// break;
// }
/* issue the received data to the output stream */
if (IOM_COMPLETED != SIO_issue(mcbspInHandle, rcv, BUFSIZE, NULL))
{
printf("Error issuing buffer to the stream");
}
pktCountIn++;
}
}
if (FALSE == fail)
{
printf("\r\nSample Application completed sucessfully...");
}
else
{
printf("\r\nSample Application failed...");
}
}
/*
* \brief Function to submit the requests to the driver
*
* \param None
*
* \return None
*/
static Void mcbspDriverPrimeIn(Void)
{
Uint32 count = 0;
for (count = 0; count < NUM_BUFS; count++)
{
if (IOM_COMPLETED
!= SIO_issue(mcbspInHandle, (Ptr)(bufIn[count]), BUFSIZE, NULL))
{
SYS_abort("Issue to output stream failed\n");
}
}
printf("Request submitted to Mcbsp Input driver.");
}
/*
* \brief Function to create the required streams for the reception of
* Mcbsp data.
*
* \params None
*
* \return None
*/
static Void mcbspCreateStreamsIn(Void)
{
SIO_Attrs sioAttrs = SIO_ATTRS;
Uint32 count = 0;
sioAttrs.nbufs = NUM_BUFS;
sioAttrs.align = BUFALIGN;
sioAttrs.model = SIO_ISSUERECLAIM;
/* create the channel for the RX operation */
mcbspInHandle = SIO_create("/dioMcbspIN", SIO_INPUT, BUFSIZE, &sioAttrs);
if (NULL == mcbspInHandle)
{
printf("RX Stream creation Failed\n");
SYS_abort("Stream Creation Failed\n");
}
/* create the buffers required for the RX operation */
for (count = 0; count < (NUM_BUFS); count++)
{
bufIn[count] = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
if (NULL == bufIn[count])
{
printf("Memory allocaton failed\n");
SYS_abort("MEM_calloc failed.\n");
}
}
}
: