CX3: How come streaming is not running infinite?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
NiEn_2817821
Level 1
Level 1
First like received

I have following code:

static int32_t DmaUsbCommitCount = 0;

void DmaCallback(

   CyU3PDmaMultiChannel* chHandle,

   CyU3PDmaCbType_t  type,

   CyU3PDmaCBInput_t* input

)

{

   CyU3PDmaBuffer_t dmaBuffer;

   CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

   if (CY_U3P_DMA_CB_PROD_EVENT & type)

   {

      status = CyU3PDmaMultiChannelGetBuffer(chHandle, &dmaBuffer, CYU3P_NO_WAIT);

      // add header

      if (3 < DmaUsbCommitCount) {

/* Discard Buffer */

status = CyU3PDmaMultiChannelDiscardBuffer(chHandle);

if (status != CY_U3P_SUCCESS) {

// error handling

}

      }

      else {

/* Commit Buffer to USB*/

status = CyU3PDmaMultiChannelCommitBuffer(chHandle, (dmaBuffer.count + SD_PROD_HEADER), 0);

if (status != CY_U3P_SUCCESS) {

// error handling

}

else

{

DmaUsbCommitCount++;

}

      }

   }

   if (CY_U3P_DMA_CB_CONS_EVENT & type)

   {

DmaUsbCommitCount--;

   }

}

As I have 6 DMA buffers, I assumed that the above code would keep the producer running (swapping between 2 buffers) while 4 buffers get stocked as committed to the USB, when the host stops reading data on the USB.

But what happens, is either that the DmaCallback stops getting called with producer events, or sometimes CyU3PDmaMultiChannelGetBuffer returns 0x45 (CY_U3P_ERROR_TIMEOUT) and then no more events are received.

How do I keep the producer running, when the USB commits are stocked?

When streaming and NOT running into the above USB stocked scenario, the DmaCallback gets called with the event type 5 (CY_U3P_DMA_CB_XFER_CPLT + CY_U3P_DMA_CB_RECV_CPLT) after steaming for a short while.

How can that be, when I call CyU3PDmaMultiChannelSetXfer(&DmaStreamingHandle, 0, 0) just before starting streaming? Shouldn’t it then run infinite?

0 Likes
1 Reply
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

The error 0x45 is returned by the API CyU3PDmaMultiChannelGetBuffer when the DMA buffers are not available for the producer sockets to fill the incoming data. Please share the debug prints which contains the prints for prod and cons events so that we can understand the issue better.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes