PIC18F26J50 serial communications over RS485 link
E0 is very typical of a baud-rate mismatch, in which the transmitter is sending at 1/6 the speed that the receiver is expecting. In your case, 9600 bps vs. 57600 bps.

You see, when you transmit 55, the actual bit sequence is ...1110101010101111..., where the initial ones are the "idle" line, the first zero is the "start" bit and the next 8 bits are the data, LSB first. The next bit after that is the "stop" bit (always a 1) and then more idle bits.

But if the receiver is operating at 6&times; the rate, it samples each bit six times, so it sees:

    start    stop
      |   E0   |
...111000000111111000000111111000...
                  |   E0    |
                start     stop


Each 1&rarr;0 transistion is seen as a start bit, the next 8 bits are interpreted as E0 followed by a stop bit, and then two idle bits.

So the answer is, your transmitter is not running at the speed you think it is. Let me guess &mdash; when you run your code, you see the E0 appearing in batches of 5 at a time, right?



I once wrote a microcontroller application that used this exact technique to "auto-baud". On power-up it set the UART to the highest available speed, and then looked at the first character received to try to measure the actual width of the "start" bit and then jump directly to the correct baud rate. Obviously, E0 was one of the patterns I was looking for.

It works as long as the first character received has a one in the LSB. Since most people hit &lt;CR&gt; as their first key, it worked like a charm!