I want to use my Apalis i.MX6 to communicate with external devices via UART. I am using the kernel version 3.14.52-rt.
In order to test the latency i connected TX and RX to create a loop (in fact this will be the case in the real design later on). I wrote a test code (attached below) which basically configures the UART and sends one byte via write(), waits until commit via tcdrain() and reads back via read().
My serial configuration is 115200 8N1, so one message byte should need around 90µs for transfer but it takes several milliseconds. So i configured a GPIO pin to go high before read and low after tcdrain and i see that tcdrain takes most of the time (see first picture). Even when i remove tcdrain and just use a “blocking” read() it takes about 700µs to recognize the message byte (see second picture).
Question is: Why do i get get such a high latency?
Note: I already edited the dtb so that the uart does not use dma (with dma its even worse).