We are using UART4 on the K64F (MK64FX512VLL112) in a RS422 situation. The RTS from the UART4 is used to control the RS422 transmitter. The problem we are experiencing is that we are getting RX overruns and don't understand why.
We are using KSDK 1.2.0 and KDS 3.0.0. This is a bare metal project.
We have reviewed this thread UART FIFO appears empty even though it is not (K64 & MQX 4.1) and have implemented those changes, see attached fsl_uart_driver.c, line 632 through 674. We are experiencing the condition of a bogus byte being received at the beginning which led us to the thread above. The Testbed_Event() function is a function we wrote that writes the event ID (first parameter) along with two other parameters to an array of data structures which are read out at a later time creating an event log or trace buffer of sorts.
In our application code we call the UART_DRV_ReceiveData() indicating we need four bytes of data. For some reason the first byte received is a byte that is not in the packet at all. We are observing the data with both a 'scope and we have another computer monitoring the data and indeed we are only receiving four bytes, but they are not as claimed by the K64F. We have seen that the RX_OVERRUN occurs approximately 27uS after the UART_DRV_ReceiveData() has been called; this is hardly 3-bit times into the first character (at 115200 baud).
Our timing is measured using the cycle counter found in the CoreSight module of the Cortex-M4. CPU clock at 100MHz. We are rounding the time to uS as that is close enough.
The serial baud rate is 115200.
Also, added test code at line 711 through 716 as we are occasionally losing transmit data for some unknown reason; maybe these two issues are related, not sure.
For the serial receive problem, I am wondering if the UART receiver is actually restarted so to speak when UART_DRV_ReceiveData() is issued or is there a way to restart or ignore any pre-existing data sitting in the UART? Or is there another angle to resolving this issue?
Any suggestions would be great!
Original Attachment has been moved to: fsl_uart_driver.c.zip