> In one of my applications, I need a serial RX/TX routine capable > to 'recognize' the speed of the serial line, so it can adjust > itself to that speed (eg. I have a '84 based 'host' to which I > want to attach few 'terminals' working at 1200, 2400, 4800, 9600 > baud). Alright, I've read a few of the suggestions on an autobauding, almost everyone included a critical point on the subject. But I didn't see one that included all of key considerations (especially importance of what the data stream looks like). 1. Is first character known? If so the baud rate can be determined by measuring the time from beginning of start bit to first bit that is a mark (logic 1). Based on where this bit is located in the character you can determine the baud rate -- i.e. if it's bit 0, then the measured time is the width of 1 bit. With this method you won't lose any characters. 2. If the first character is unknown, you must consider what the data stream "looks like"? Is the stream continuous? Are the characters "back to back"? (It's very simple to transmit data at 9600 baud without any space between charaters) Is there a pattern (CR/LF after every 80 characters for example)? If characters are are at least 8.33milliseconds apart (1 character at 1200 buad), then measuring the time from start bit to stop bit will work (with 8.33 millisecond timeout of course). You always lose one character with this method. Worse Case: If the characters are continuous, back to back and with no pattern (and first character unknown), ahhhhhh ---- what in the world are you going to do with this anyway (just kidding)? If this is the case, it's rather difficult to get in sync and determine the baud rate (data better not be critical!). You can try keeping track of the shortest 1-0-1 width time (obvious limit this to .104 milliseconds --1/9600). For example: a 1-0-1 width of .208 ms, can't be 1200 & 2400 baud but can be 4800 or 9600, so you assume 4800 until you measure one of .104 ms. You will need to get in sync with the start bit as well (stop bit must line up on every character -- if not try again). As you can see, several methods of autobauding will work, but you need to know what the datastream looks like before you can determine which method is best. :) Rod rdemay@bb-elec.com