>> I suspect you will need to be a bit more proactive about how >> you detect the first character. For example take the character >> 'A', that is binary 01000001 Assuming US-ASCII character set and 8-bit no parity framing (or 7-bit data portion plus even parity or mark (I think) parity). These are fairly common settings, but not the only ones used. >> case 1 - character seen in your test is 10011111 or 00001111 >> then baud rate at the receiving end is probably half the >> transmitted baud rate. > Ok, I got this one, but why are the rest 1 and not 0? If your hardware UART is set for a faster baud rate than the sender is using, then the sender's start bit will slop over into the data bits portion. This artificially widened start bit is the source of the "extra" 1's bits. >> If you can arrange to measure the bit widths on the pin then >> you will probably arrive at the required baud rate a lot quicker. > Exactly what do you mean? Normally, auto-baud is done by measuring the width of a single bit. That bit is normally the start bit of the frame. To ensure that a single bit is measured, the first data bit (low order bit) has to be a 1. This criteriun is met by the sending using an ASCII character of carriage return, '1', '3', '5', '7', '9', 'A', 'a', 'C', 'c', 'E', 'e', etc. All that matters is that the low order bit of the character is a 1. Wire the receive data line to a pin. Watch the pin for voltage transition (direction depends on your hardware). Start a timer. When you see the next transtition, stop timer. Invert bit time (via table or If-Else tree) into baud rate. Program hardware UART. Then check next character for validity & framing. If it doesn't "look right", start over. carriage return, ASCII '1', ASCII 'A', ASCII 'a', Someone else replied: > The character for [a US-ASCII] 'A' will have a picture like > this on an oscilloscope [...]. A capital S is a start bit, and > a lower case S is a stop bit. > > _____ _____ __________ > waveform | S | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | s | S | > ----------- -------------------------- ------ This diagram shows the bits being sent most significant bit first. It is reversed. This is incorrect. Serial data is transmitted low order bit first. It has to be since the number of bits per byte may vary. Common sizes have been 5 bits/byte up to 9 bits per byte. Lee Jones -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body