LPC4337 and serial RX DMA stall

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by tkrill on Mon Aug 17 10:54:45 MST 2015
Hi All,

I have a problem with serial RX dma stalling during transfer on a custom lpc4337 board. We run the serial port in 921600 baud and unfortunately the operating system, Linux 4.x, seems to have a bit to high latency to keep up with this speed.

Because of that we enabled DMA transfers on both RX and TX. Transfers seems to work nicely we however have a problem with receiving data and I'm not sure where to proceed debugging.

The problem is something like this. During sporadic reception of data, below the threshold fifo interrupt level, we use normal interrupt and empty the FIFO. When the fifo threshold is exceeded the driver instead sets up a DMA transfer to read out the incoming data.

When doing this there is no way for the driver to estimate the amount of data that is expected thus the driver sets the transfer length to 4096 bytes (One page) and starts the DMA transfer.

Now to the problem, when the data is less than the 4096 bytes the DMA transfer stalls waiting for data.

As far as i understand the device driver it relies on the character timeout interrupt, CTI, to fire when no more data arrives on the serial line.  From the manual:

"The CTI interrupt (IIR[3:1] = 110) is a second level interrupt and is set when the USART Rx FIFO contains at least one character and no  USART Rx FIFO activity has occurred in 3.5 to 4.5 character times."

This interrupt never fires during DMA transfer in progress. (It works nicely otherwise though)

My questions are:

Why do we not see the CTI interrupt during DMA transfers?

How is one supposed to handle RX DMA when the amount of data to receive is unknown? I.e. how else could we solve our problem.

Best Regards,