Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A Asynchronous connection question

How does the receiver understand the end bits? It doesn't. The purpose of stop bits (what you seem to be calling "end bits") is to leave a guaranteed gap before the next start bit. The leading e...

posted 3y ago by Olin Lathrop‭

Answer
#1: Initial revision by user avatar Olin Lathrop‭ · 2021-11-26T15:33:59Z (almost 3 years ago)
<blockquote>How does the receiver understand the end bits?</blockquote>

It doesn't.  The purpose of <i>stop bits</i> (what you seem to be calling "end bits") is to leave a guaranteed gap before the next start bit.

The leading edges of start bits are always idle to non-idle transitions.  The line must therefore always be at idle before any new character.  The stop bit(s) of the previous character guarantee that.

For modern digital communication, a single stop bit is sufficient.  Early equipment that received asynchronous serial protocol used mechanical means for decoding, such as the common ASR-35 teletype back in the 1970s.  Those mechanisms sometimes needed more than one bit time to reset to being ready for the start of the next character.  It was common then to send two stop bits.  Some operations that took more time, like a carriage after a long text line, might require 3 stop bits.  There were algorithms to optimized the number of stop bits, taking into account the characteristics of the receiving equipment, like an ASR-35.

<blockquote>In my case the last 2 0s could have been the end bits but instead the receiver understand the last two 0s from 0100100(0) are actually part of the data</blockquote>

Right, because receivers don't "decode" stop bits.  Transmitters and receivers have to agree ahead of time how many bits follow the start bit, and how long each of those bits take.  Receivers then just grab the value of the line near the center of where each bit is supposed to be.  Nothing in the data encodes where the data ends.  Everything is relative to the leading edge of the start bit.

This is why you have to specify protocol details when using RS-232.  You may have seen specs like "9600 baud, 8 data bits, no parity bit, 1 stop bit".  This is often abbreviated as "9600 8-N-1".  Your example uses 7-E-1, meaning 7 data bits, even parity, and 1 stop bit.

Note that the stop bits spec is a minimum.  There can be any arbitrary additional gap between characters.  The receiver can't distinguish between 8-N-1 with an additional 1-bit delay between two characters, and two characters sent with 8-N-2.