It looks like your send routine takes up so much time that it doesn't get back to HSERIN before the receive buffer overflows. Your CLOERR define clears the overflow error, but that also dumps the buffer. As a result, you are losing characters.
It looks like you need an interrupt-driven receive routine.
Are the characters coming in continuously, or in bursts?
Bookmarks