Start and Stop Bit (Serial Communication)

user3225006 picture user3225006 · Mar 5, 2016 · Viewed 15.1k times · Source
  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?

Answer

old_timer picture old_timer · Mar 5, 2016

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.