LPC845 : DMA : how to load next dma_descriptor_t before transfert completion?

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC845 : DMA : how to load next dma_descriptor_t before transfert completion?

66 Views
Contributor III

Hello,

I have configured the DMA to use a ping pong buffer. Using DMA_GetRemainingBytes() I am able to get the transfer count. I want to manually switch the DMA to the other buffer without waiting for the DMA transfer completion. How can I do this?

And regarding to the context of this project, I am modifying the USART DMA example from the SDK of the LPC845 in order to add a timeout. The buffers are 50 bytes long.

while (1)
{
for(volatile int i =0; i <1000000; i ++)
{
}

PRINTF("\nloop\n");

DMA_DisableChannelInterrupts(EXAMPLE_USART_DMA_BASEADDR, USART_RX_DMA_CHANNEL);
uint32_t bytes_transfered = DMA_GetRemainingBytes(EXAMPLE_USART_DMA_BASEADDR, USART_RX_DMA_CHANNEL);

uint32_t inta = (EXAMPLE_USART_DMA_BASEADDR->CHANNEL[USART_RX_DMA_CHANNEL].XFERCFG >> 4) & 1UL;
uint32_t intb = (EXAMPLE_USART_DMA_BASEADDR->CHANNEL[USART_RX_DMA_CHANNEL].XFERCFG >> 5) & 1UL;

//CODE HERE TO SWITCH TO THE OTHER BUFFER

DMA_EnableChannelInterrupts(EXAMPLE_USART_DMA_BASEADDR, USART_RX_DMA_CHANNEL);

bytes_transfered = BUF_LEN - bytes_transfered;
PRINTF("bytes_transfered = %d, inta = %d, intb = %d",bytes_transfered,inta,intb);
}

pastedImage_2.png

Thanks in advance,

Victor

Tags (2)
0 Kudos
1 Reply

23 Views
NXP TechSupport
NXP TechSupport

Hello Victor Canoz,

"I want to manually switch the DMA to the other buffer without waiting for the DMA transfer completion. How can I do this?"

-> How about stop DMA and re-config it ?

0 Kudos