UART frame has 1 start bit, 8 bit payload data, 1 or 2 stop bits. Frame structure and baud rate is agreed by both transmitter and receiver for successful data transmission. Start bit is used to synchronize and tell receiver that frame is started. Why there is a need of stop bit per frame, since all data frame to be transmitted will always be 8 bits (frame will always end with 8 bits)?
-
stop bits are added to a communication protocol in case of unforeseen interference. In phone modems, we added this especially to handle communication issues with poor quality phone lines. – David Mikeska Apr 26 '21 at 16:35
-
This comment may be relevant: https://electronics.stackexchange.com/questions/608214/can-serial-communication-always-be-encoded-with-8-n-1-schema/608215?noredirect=1#comment1601422_608215 – smwikipedia Feb 13 '22 at 02:44
3 Answers
(sorry: I'm in lecturer mode)
What will the line signal look like (without a stop bit) when you transmit a continuous stream of 0x00 bytes? which problem will this cause?
- 48,572
- 1
- 63
- 136
-
For 9 bit (1 start bit + 8 data bit), UART lines will be 0 (9 spaces). – Avadhana Technologies Oct 17 '15 at 07:37
-
1
-
8The point is that it will always be 0. Hence the receiver (which can have a clock that differs somewhat from the sending clock) will (after some time) lose track of where the bytes start. Hence 1000 bytes sent could be received as 999 or 1001 bytes. – Wouter van Ooijen Oct 17 '15 at 08:19
-
1I dont get it. Why wiuld he lose track if there is a predefined baud rate? I mean, the receiver should know that a bit should arrive each x time..? – YoavKlein Apr 01 '21 at 13:48
-
Yes, but x can't be EXACTLY the same at sender and receiver. That is physically impossible. – Wouter van Ooijen Apr 26 '21 at 16:27
-
1The difference is assuming the data within a 8bit count vs knowing the 8-bits of data originated from the transmitter. if the frame size was skewed due to poor wiring, it couldn't tell the difference, and shift all the data and garbage bits from noise in. With a stop bit in certain communications, it has a frame reference and if it goes outside that frame reference it will send a retry bit back to the transmitter and error correct the transmission. – David Mikeska Apr 26 '21 at 16:47
What is used for synchronization is not the start bit itself, but the falling edge between the previous stop bit and the start bit.
Without both stop and start bits, there might not be such an edge.
- 19,292
- 5
- 42
- 68
-
-
3
-
Then why not just add a single one stop bit after all the data has been sent rather than have a stop bit for every frame of data. – smwikipedia Feb 12 '22 at 14:22
-
@smwikipedia The "A" in "UART" stands for "asynchronous". Sender and receiver have their own clocks, so they must regularly re-synchronize. – CL. Feb 12 '22 at 18:00
-
@CL. Thanks. To be honest, I don't have a practical experience about how bad the clocks of the two parties can differ. But even if we add stop bits for every frame, how could that make everything in sync? After all, the stop bits don't touch the receiver's clock (not sure if I am right on this). And if the receiver's clock is wrong, it will always be wrong. – smwikipedia Feb 13 '22 at 01:38
-
@smwikipedia The clocks differ by no more than a few percent, but that will add up over many bits. – CL. Feb 13 '22 at 09:40
It's a holdover from the days of electromechanical teletypewriters, when the time was used to release a clutch in the electromechanical transmitter mechanism. It was carried forward into fully electronic UARTs, perhaps because the original electronic designers didn't understand electromechanical teletypewriters.
Here's a discussion of how the old teletypewriters worked: http://mysite.du.edu/~jcalvert/tel/teletype.htm
- 21
- 3
-
1That's a valid reason for adding extra stop bits, but you always need at least one, as described in the other answers, in order to guarantee having at least one transition in the signal for every byte transmitted, even with back-to-back characters. – Dave Tweed Dec 16 '15 at 15:03