Hello,
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:
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?
Thank you.
Hi,
To clear OR, read S1 when OR is set and then read UART data register (D). so you may do the following in the error ISR:
/* Read and save the S1 value */
status = UART_S1_REG(channel);
/* Check to see if a receiver overrun has been detected */
if (status & UART_S1_OR_MASK)
{
printf("\nUART receiver overrun detected.\n");
num_or_errors++;
/* Read data register to clear the flag */
temp = UART_D_REG(channel);
}
If the problem is still there, please check whether the host ontinues to send cyclic requests in that case. You may disable the RX function before clearing OR flag and never enable it, and see if OR interrupt happens anyway.
Hope that helps,
B.R
Kan