CyU3PDmaChannelGetBuffer with NO_WAIT (not available)

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

cross mob
Christophe
Level 3
Level 3
25 sign-ins 10 replies posted 5 questions asked

Hello,

I have an application with MANUAL_IN & MANUAL_OUT dma channels.

When I use CyU3PDmaChannelGetBuffer with NO_WAIT it bugs. Buffers should be available at start I believe ? Is it possible to fill the buffer quickly than they are consumed ? When using with WAIT_FOREVER it works, but sometimes I have around 20ms between two buffers. As I need to acquire the data as quickly as possible it doesn't match for my application.

/* Create a DMA MANUAL IN channel for the producer socket */
CyU3PMemSet((uint8_t*)&dmaCfg, 0, sizeof(dmaCfg));
dmaCfg.size = size;
//dmaCfg.size *= CY_FX_DMA_SIZE_MULTIPLIER;
dmaCfg.count = CY_FX_BULKLP_DMA_BUF_COUNT;
dmaCfg.prodSckId = CY_FX_EP_PRODUCER_SOCKET;
dmaCfg.consSckId = CY_U3P_CPU_SOCKET_CONS;
dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;
dmaCfg.notification = 0;
dmaCfg.cb = NULL;
dmaCfg.prodHeader = 0;
dmaCfg.prodFooter = 0;
dmaCfg.consHeader = 0;
dmaCfg.prodAvailCount = 0;

/* Create a DMA MANUAL OUT channel for the consumer socket */
dmaCfg.notification = 0;
dmaCfg.prodSckId = CY_U3P_CPU_SOCKET_PROD;
dmaCfg.consSckId = CY_FX_EP_CONSUMER_SOCKET;

 

The production of data:

 

while(stat == CY_U3P_SUCCESS && buffersIndex < numberOfBuffersRequired) {

// Number of sample we still need to get so far
numberOfSampleWeStillNeed = count - numberMaxOfSampleInABuffer * buffersIndex;
// Compute the number of iteration to be done in a single buffer
numberOfIterationSingleBuffer = numberOfSampleWeStillNeed > numberMaxOfSampleInABuffer ? numberMaxOfSampleInABuffer : numberOfSampleWeStillNeed;

//stat = CyU3PDmaChannelGetBuffer(p_dmaChannel, &dmaBuffer, CYU3P_WAIT_FOREVER);
stat = CyU3PDmaChannelGetBuffer(p_dmaChannel, &dmaBuffer, CYU3P_NO_WAIT);

samplesIndex = 0;
interruptMask = CyU3PVicDisableAllInterrupts();
while(stat == CY_U3P_SUCCESS && samplesIndex < numberOfIterationSingleBuffer) {

SPI_RECEIVE_WORDS_OPTIMIZED_MA

GPIO_COMPLEX_SAMPLE_NOW_OPTMIZED_MA

samplesIndex++;
}
CyU3PVicEnableInterrupts(interruptMask);

dmaBuffer.count = numberOfIterationSingleBuffer * 6;
stat = CyU3PDmaChannelCommitBuffer(p_dmaChannel, dmaBuffer.count, 0);

buffersIndex++;
}

0 Likes
1 Solution
Christophe
Level 3
Level 3
25 sign-ins 10 replies posted 5 questions asked

Well, the issue comes from the consumption of the data not the FX3.

I had some delay sometimes because the computer goes on other processes and my buffer were fully filled. I reduced a lot the probability of that happening by using the full DMA Buffer Memory Area. With bigger buffer and more of them.

Regards, Christophe

View solution in original post

0 Likes
2 Replies
Bakal
Moderator
Moderator
Moderator
100 sign-ins 25 solutions authored 50 replies posted

Hello,

can you please elaborate a bit more clearly on your query? 
and include what exactly you want to achieve.
Have you used any pre-defined FX3 code example and edited, it let me know.  
Also, do share your firmware code example So that will look into it. 

Best Regards,
Sakshi Bakal

0 Likes
Christophe
Level 3
Level 3
25 sign-ins 10 replies posted 5 questions asked

Well, the issue comes from the consumption of the data not the FX3.

I had some delay sometimes because the computer goes on other processes and my buffer were fully filled. I reduced a lot the probability of that happening by using the full DMA Buffer Memory Area. With bigger buffer and more of them.

Regards, Christophe

0 Likes