Start and Stop Bit (Serial Communication)
Asked Answered
G

1

7
  1. What will happen if there is no Start and Stop Bit in Serial Communication?
  2. What is the use of Start and Stop Bit?
Guitar answered 5/3, 2016 at 3:26 Comment(1)
1: it won't work. 2: it makes it work. The start bit tells the receiver that it is about to receive a byte and should interpret the next ones as data bits. The stop bit is a very basic error check to detect a baudrate or byte length mismatch. Not every serial communication protocol uses them, a synchronous protocol like SPI doesn't. Asynchronous signaling like this is inspired by hardware design, an UART chip takes care of the transmitting the byte so the time between bits is very deterministic. But bytes are generated by software, the amount of time between them is not predictable.Bruxelles
N
13

The whole collection of bits is a packet if you will. the start and stop bits are otherwise indistinguishable from data bits. Say for example you have one start bit, one stop bit, no parity and 8 data bits. That means there is a low bit (start) 8 data bits (can be any one of the 256 combinations) and high bit (stop). The receiver has to be told that this is 8N1 so it is looking for a low, 8 bits and a high, if it doesnt see that then it is not locked on the data, and most likely it basically discards the first bit, shifts in one more, then looks for a start and stop with 8 in the middle. Once it sees that then it assumes it is real data and allows the byte/character in to the receive buffer. If the next 10 bits dont have that start 8 bits stop pattern, then that is a framing error and it starts searching again. so if this pattern comes in

000000000000011111

the first 10 bits do not have a start and stop

0000000000

so discard the first zero and try again

00000000000011111

0000000000

nope, still no start and stop

this repeats until the serial stream shifting in looks like this

00000000011111xxxxxxxxxxx

0000000001

we have a start, 8 bits and a stop, so we consider that a good character 0x00 save 0x00 in the rx buffer.

starting with the next bit after the stop bit we take the next 10

1111xxxxxxxxxxx

and that does not start with a start bit, so that is a framing error

1111xxxxxx

we go back to searching for a start bit 8 bits and a stop bit.

if you use a parity bit then it is the same but not only do you need a start and stop, but you need the bits in the middle to have a certain parity, even or odd. so to get a good character you need start, some number of bits with the correct parity and a stop bit, then you can extract the character and start after the stop bit looking for another start bit.

Nitrogenous answered 5/3, 2016 at 4:2 Comment(1)
and if you have two stop bits instead of one, then again the pattern has to match to call it a good character, start bit, n data bits and two stop bits. The use of the start and stop bit is to find the byte/word boundaries within a serial stream. In order to convert from serial to parallel you need to have a scheme to find the word/packet boundaries.Nitrogenous

© 2022 - 2024 — McMap. All rights reserved.