Here's how to reproduce the issue:
- Import the evkmimxrt1010 lpuart_edma_transfer example, using SDK version 2.8.2
- Apply the following patch (the code between TEST BEGIN and TEST END) to the main function (this is showing my use case)
- Press a button on the debug console so that the MCU receives a byte of UART data
while (1)
{
/* If RX is idle and g_rxBuffer is empty, start to read data to g_rxBuffer. */
if ((!rxOnGoing) && rxBufferEmpty)
{
rxOnGoing = true;
LPUART_ReceiveEDMA(DEMO_LPUART, &g_lpuartEdmaHandle, &receiveXfer);
}
// TEST BEGIN
{
lpuart_transfer_t received = receiveXfer;
LPUART_EnableRxDMA(DEMO_LPUART, 0);
// ensure no DMA data is cached
__DSB();
int status = LPUART_TransferGetReceiveCountEDMA(DEMO_LPUART, &g_lpuartEdmaHandle, (uint32_t*)&received.dataSize);
if (status == kStatus_NoTransferInProgress)
{
// if the transfer is complete, the length isn't modified
// transferred.dataSize = mEdma.rxDataSizeAll;
}
if (received.dataSize == 0)
{
// nothing was received, just re-enable feeding DMA
LPUART_EnableRxDMA(DEMO_LPUART, 1);
}
else
{
// need to abort current transfer before starting a new one
LPUART_TransferAbortReceiveEDMA(DEMO_LPUART, &g_lpuartEdmaHandle);
// switch to other buffer
LPUART_ReceiveEDMA(DEMO_LPUART, &g_lpuartEdmaHandle, &receiveXfer);
}
}
// TEST END
/* If TX is idle and g_txBuffer is full, start to send data. */
if ((!txOnGoing) && txBufferFull)
{
txOnGoing = true;
LPUART_SendEDMA(DEMO_LPUART, &g_lpuartEdmaHandle, &sendXfer);
}
/* If g_txBuffer is empty and g_rxBuffer is full, copy g_rxBuffer to g_txBuffer. */
if ((!rxBufferEmpty) && (!txBufferFull))
{
memcpy(g_txBuffer, g_rxBuffer, ECHO_BUFFER_LENGTH);
rxBufferEmpty = true;
txBufferFull = true;
}
}
The result is:
The abort and restart is unsuccessful, which leads to the same byte being reported as received, and no further data reception is happening.