??? 08/05/11 14:15 Read: times |
#183220 - Much to a real UART Responding to: ???'s previous message |
The majority of real UART requires 16 times the baudrate as input clock, to get better at handling noise. Some few UART just runs at 8 times the baudrate.
So why 16 times the baudrate? First off, they sample for the start bit, and a high sampling rate means they will be better synchronized - important if there is a baudrate mismatch (more common earlier when everything didn't have a high-quality crystal to generate the frequency). Next thing is that they take multiple samples of the start bit, to avoid capturing a byte for a very short pulse. Next thing is that they normally takes 3 samples in the middle of each bit, and use majority vote to decide if it's a high or low bit. This improves the noise immunity. Making sure that the three samples are in the middle of the bit (not too close to start or end of bit) makes sure that a slight baudrate error will not result in one of the samples reaching the previous or next bit. Finally, they perform a careful check for the stip bit(s), which will spot two error causes: - a hung signal line constantly generating the start condition. - transfer synchronized to the middle of a byte transfer, in which case a data bit is incorrectly assumed as a start bit. Then you normally get following start bit or random data bits where the stop bit(s) should have been. If you do send your bytes with a short, or none, pause between stop bits and next start bit, and the data have specific content, then you could get an UART to continuously error-sample the data. The use of dual stop bits reduces this probability by improving the chance to detect a framing error - but obviously fails with that depending on transmitted bytes. This is also the reason why packed-based communication normally have a pause of more than one full character transfer time between packets - then the next packet will start correctly synchronized. In the end, a single-sampling software UART will have much worse behaviour than a hardware UART with the exception that it might possibly be quicker to synchronize with start bits. |