Serial Port Silliness

Do you frequently use serial ports without a second thought? All you need is RX, TX and GND for a basic configuration along with some RS232 or MIL-STD-188 drivers for the cable, right? The fact that the bits are transmitted asynchronously is implied. The only difference between a Data Terminal Equipment (DTE) device and a Data Circuit Terminating Equipment (DCE) device is just the connector pinout. At least that’s what I always assumed.

That was until I saw a product using synchronous RS232. I was so shocked that I read the RS232 and MIL-STD specifications and they both include transmit and receive clock lines. I had no idea! The best part was that the product was configured as a DTE which meant that the transmit and receiver clocks were inputs. That’s usually not a problem when there’s a DCE in the system but I had to get 2 DTE’s to communicate with each other without a DCE. Since the products only needed the clocks to work I thought it would be easy, but I was wrong.

The system was setup so that product A would transmit its data to product B that would receive it. Fortunately the serial protocol was really simple and allowed this type of connection. All I had to do was supply the transmit and receive clocks for the pair which is what I did using a microcontroller development board. The board generated 2 clock signals 180 degrees out of phase at RS232 voltage levels using a level translator already on the board. My first try was within 2 Hz which I thought would be good enough.

So I tried it. And it didn’t work. After a little thought and testing it was apparent that the clock generator wasn’t accurate enough. Product A expected to transmit data at a fixed rate and Product B wanted the data at a fixed rate. Because my clock generator was 2 Hz slow that was 2 bits per second that weren’t being transmitted on time which snowballed and eventually degraded system performance. The solution? Get the clock generator within 0.02Hz of the desired frequency or 33ppm. Since a typical crystal is accurate to 50ppm, this should work but isn’t guaranteed since the product crystals could be up to 100ppm out of tolerance with each other. But at least now it takes a long time before there will any bit errors.