I'm developing for the K10 MCU, CD IDE 10.4, compiler GCC 4.7.3.
The MCU has one block of the Flash program memory, 512Kb overall, no EEPROM.
Our device communicates with some host through UART serial interface, over half duplex RS485 differential line.
The device is defined slave, so it responses to the host's asynchronous cyclic requests with some application data.
The device responds to requests by UART RX ISR.
If the communication cable is disconnected, the host declares a timeout fault, but continues to send cyclic requests.
The host implements a clear fault command, which resets the communication in SW from the host side So, if the cable is connected back to the slave device, this clear faults command
is supposed to resolve the communication.
The slave device implements a handling of UART errors, which is supposed to resolve the errors and bring back proper UART RX interrupt handling.
I'm clearing the UART error in the UART error interrupt handler according to the reference manual:
- Disable receiver.
- Flush RX FIFO.
- Read UART_S1.
- Read UART_D.
- Clear RX underflow flag in UART_SFIFO.
- Enable receiver.
This doesn't resolve the communication. The slave device gets overrun error, which is cleaned by the above sequence, and stops with UART RX interrupts.
Am I doing something wrong with the error handling? How the overrun error is supposed to be cleaned?