>> 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? Well they may not be 1's, it will depend on how many stop bits the transmitter is programmed to send, and how soon after the first character the next character is sent. If it is all set up for 1 stop bit, and the next character is sent immediately then you may end up with seeing 10011xxx or 00001xxx where xxx will depend on the next character >> case 2 - character seen at receiving end is 00011000 then baud rate at >> receiving end is probably twice the transmitter. (stop and think about why >> there is an extra 0 at the left hand end). >I can't find a good answer... See diagram below >> case 3 - character seen at receiving end is 00000001 then baud rate at >> receiving end is probably 4 times the transmitted baud rate. (again think >> about what happens with the start bit). >If there is one extra 0 in the beginning like in case 2, why isn't it >00000111? Again see diagram below >I tried to compare with those but the only one working was the baud >rate I started with. I think the program didn't get out of the loop that >receives the first byte. >> 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? The character for an 'A' will have a picture like this on an oscilloscope (except there will not be all the vertical lines I have put in to show the boundaries of the bits). A capital S is a start bit, and a lower case S is a stop bit. I have shown the start bit of the next character assuming it follows immediately after the first. _____ _____ __________ waveform | S | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | s | S | ----------- -------------------------- ------ rx at baud rate ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ rx 1/2 baud rate ^ ^ ^ ^ ^ ^ ^ rx 2x baud rate ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ rx 4x baud rate ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ each arrow represents a sampling of the waveform by the UART to determine the state of the bit that is to be shifted into the register. The very first arrow represents the beginning of the start bit that starts the UART receiving a character, the next arrow the UART verifies it is a proper start bit, not a noise pulse, and then the next 8 arrows are the 8 data bits, The arrow after that is to determine that there is a correct stop bit. If this is not correct you will get framing errors. Now from the above picture you can see that at the correct baud rate, the data starts from the 3rd arrow, and then is sampled as 01000001, which is correct for 'A'. At half the baudrate the first data bit is still a 0, so a proper start bit is seen, and the data shifted into the UART will be 0001xxx on my picture. At the 2x baud rate the first data bit seen is actually 3/4 way through the start bit, so you would have 00011100 as the first character, the next bit that should be a stop bit will be a 0 instead of a 1, and so will produce a framing error. This requires corrective action in PIC code for the uart to work correctly afterwards. At 4x baud rate the first data bit will be seen only half way through the start bit, so the data will look like 00000000 and as the next bit is a 1 then it will see a valid stop bit, and so there will be a second character following of all 0's, which in this case will have a framing error. My data bits in the previous email were a bit out as well from mentally shifting bits instead of drawing diagrams. If you are not aware of why there are start and stop bits, then learn a little theory on how serial transmission with a UART works. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body