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);
}
Thanks in advance,
Victor
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 ?