Nick Buters

K64 eDMA UART missing bytes

Discussion created by Nick Buters on Nov 9, 2017

I'm trying to use the eDMA UART module on a Kinetis K64. Code has been based on the example from the SDK.

Everything works ok during normal operation, but when a bad packet is received (eg. frame error) the Kinetis stops receiving and the eDMA receive operation never completes.


I would like to be able to recover from errors (parity, framing, noise, etc) by discarding the data in the buffer and starting a new receive operation. I've written some code to check status flags for errors and start a new receive operation when an error is detected;


uint32_t active_flags = UART_GetStatusFlags(p_base);
uint32_t error_flags = kUART_NoiseErrorFlag | kUART_FramingErrorFlag | kUART_ParityErrorFlag; 
if (active_flags & error_flags)
   UART_TransferAbortReceiveEDMA(p_base, &uart_edma_handle);
   UART_ClearStatusFlags(p_base, error_flags);


   uart_transfer_t xfer;
   xfer.dataSize = RX_BUF_SIZE; = rx_buf;
   UART_ReceiveEDMA(p_base, &uart_edma_handle, &xfer); 



This isn't working. After the receive operation is restarted the subsequent data coming in on the RX line gets missed. Calls to UART_TransferGetReceiveCountEDMA() return 0. Eventually, after a few seconds and many bytes of missed data, it starts receiving again.


Any ideas what could be causing this?