Here is a real-life story about how PC serial port baud rates are _not_ exact! I had an application that required receiving an async serial data stream of an unusual structure: 1 start bit + 240 data bits + 2 stop bits. Obviously no hardware UART in the world is going to handle that. Also obviously, this will be about 30 times as sensitive to timing error as 8N1 communications. Well, I built a bit-banged UART based on a PC platform (actually an embedded PC product). I needed a high-accuracy clock for sampling the input signal (which I brought in through the CTS signal on COM1). Instruction cycle counting was out of the question (with caches, poor documentation, etc.). After a bit of thinking, I realized that if I programmed the UART to operate at 9600 baud, 6 data bits, 1 start bit and 1 stop bit, that it would be ready for a new character every 8/9600 of a second, or 1/1200 of a second (my desired baud rate). So I just kept the transmitter supplied with dummy characters (which I just let fall of the end of the TX wire), and every time it was ready for a new one, I sampled the input on the CTS signal. Well, everything worked pretty well on a desktop machine I started with, but when I tried using the real hardware I started getting all kinds of comms problems. I tried a bunch of different machines with varying levels of success. Well, to make a long story short, the problem is that the various PC's were using various clocks for the baud rate. In fact, it seems that common design practice these days is to find some 'close' frequency on the motherboard that can be divided down to something approaching the correct input frequency for the UART chip. I way errors of as much as 0.2%, which were more than sufficient to kill my communications. I solved my problem by recoding, basing my timing on the system timer chip instead of the UART. Bob Ammerman RAm Systems (contract developer of high performance, high function, low-level software) -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements