Tuesday, December 1, 1998

An introduction to serial communications


By Alan Jay Weiner

Communications is the name of the game -- without some way to get data in and out, computers are useless. Of course, you enter data directly on the Palm device using the stylus, tapping on the screen and writing with Graffiti. And the Palm device responds by displaying information on the screen. But I think the single most important feature -- the one that really makes the Palm device stand out -- is its ability to HotSync mobile data to the desktop. Literally in a moment or two, you update all changes and back up your data. This HotSync operation takes place over the serial port.

When not used for HotSync operations, the serial port is available for other applications to use. For example, elsewhere in this issue, Fredlet reviews the GoType keyboard, which uses the serial port to capture keystrokes and then a small software driver interprets the data from the port into letters typed.

This month we take a look at using the Palm device serial port.

Serial communications in a nutshell

As you might expect, serial ports send the data bits serially; one after another. Each bunch of bits makes up a byte of data (i.e., a character), but the data stream also includes additional bits to tell the receiver that a data character has started and finished. Each data character may also include a "parity" bit for error detection.

A special piece of hardware is usually used to handle all this. Typically referred to as a UART, there are other parts that perform similar functions and are officially known by different names. UART means Universal Asynchronous Receiver-Transmitter -- but it's much easier (and quite a bit cooler) to just say "you-art." The UART takes a byte of data from the computer, handles any control lines as needed, adds the framing (start, stop, parity) bits, and does the reverse for any received data.

The simplest serial connection consists of three physical connections (e.g., wires) -- a signal ground, receive data, and transmitted data. Actually, you could have a two-wire connection if you were only transmitting or only receiving. Usually there are some additional "control" lines that tell the equipment "I'm ready for you to send to me," or "I'd like to send to you now." Examining the full serial specification (known as RS-232) is beyond this article, but for now just understand that control lines exist, and if the equipment uses them, they need to be driven appropriately or you won't get data going back and forth.