[En-Nut-Discussion] 9-Bit UART Communication

Harald Kipp harald.kipp at egnite.de
Wed Dec 3 21:24:56 CET 2003


Hi,

I'd like to ask the list for opinions.

First of all my special thanks to Brett Abbott for
his 9-bit UART driver contribution. As other users
confirmed, this code is working reliable. But, as
contributors know me, I'm not easy to satisfy...not
even with my own code. :-)

Brett's code uses a second buffer to store the
additional bits.

The ninth bit is used to indicate an address frame.
Thus, most of the characters will be transmitted with
the ninth bit cleared. In addition, the ATmega has
a special provision to ignore frames without the
ninth bit set. Simply enhancing the I/O buffers from
8 to 9 bits will not use the benefit, discarding
data frames with MCU interaction on a bus system, which
are not addressed to the local MCU.

One idea is to use a special ioctl to switch the
transmitter or the receiver to MPCM or back.

A second idea is to define a frame start/stop sequence,
let's say 0xFF 0xFF and use 0-byte stuffing for
sending this as normal data. I mean, if you need to
send 0xFF 0xFF and the UART is working in 9-bit mode,
you must send 0xFF 0x00 0xFF. The same is true for
the receiver side. If 0xFF 0xFF is received as data,
the application will get 0xFF 0x00 0xFF.

I'd vote for the first one, using an ioctl. To keep
it simple, the buffer must be flushed before switching
modes. But I think that this fits to the typical usage
of 9-bit communication anyway.

Please let me know your view. Critics and even flames are
welcome. There will be no new UART driver until I hear
from you, basta. :-)

Harald




More information about the En-Nut-Discussion mailing list