1
\$\begingroup\$

When explaining UART communication it is told that the receiver will start sampling the data one start bit after the first falling edge. The falling edge occurs when TX goes from idle state to zero as shown follows:

enter image description here

So normally above the receiver listens the TX line and when it detects idle voltage goes to zero the sampling starts one bit after.

What is not clear to me is that imagine the following scenario where the receiver is turned on and started to listen the TX line at the point I marked in red below(on the leftmost):

enter image description here

In this case will the receiver think(interpret) bit1 and bit2 as idle and the first byte will be received wrong?

\$\endgroup\$
  • 2
    \$\begingroup\$ Your opening sentence is incorrect. It will sample 1.5 bits after the first falling edge. \$\endgroup\$ – Andy aka Feb 13 at 16:01
  • 1
    \$\begingroup\$ Yes, and I have seen it happen if I send the same pattern and unplug then re-plug the cable. \$\endgroup\$ – Oldfart Feb 13 at 16:01
  • \$\begingroup\$ @Andyaka Is the start bit duration 1.5 times longer than the data bit duration? \$\endgroup\$ – GNZ Feb 13 at 16:02
  • \$\begingroup\$ @Andyaka Oh I see what you mean it samples at the middle of the data bit so it becomes 1.5. \$\endgroup\$ – GNZ Feb 13 at 16:03
  • \$\begingroup\$ @Genzo correct. \$\endgroup\$ – Tom Carpenter Feb 13 at 16:03
3
\$\begingroup\$

Yes, it will misinterpret things.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

If you turn the receiver on after the start of a data word, then of course, the receiver will not interpret it correctly. You could regard this as misusing, rather than using a link.

If the word is immediately followed by a further word, then the misalignment can continue. As long as bit 2 is 1 and bit 3 is zero, the RX will 'see' a start edge at the time it expects.

It's only when there's a pause in the transmission for long enough, so idle time of one word duration, that the RX is guaranteed to properly be able to synchronise to the start of the next word.

If a communication system is to be designed so that it can be plugged in after a transmission has started, then the protocol will have to be designed so that words can be missed, potentially garbled words are validated with, for instance, checksums, and pauses are allowed for resynchronisation. Without these precautions, a misused serial comms link could potentially misbehave forever.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ What do you mean by misused serial comms? Since we cannot change the protocol settings or hardware, do you mean by using in our coding(such as firmware C code) we should eliminate it? Quote "so idle time of one word duration," Can that be modified if we have a UART chip? \$\endgroup\$ – GNZ Feb 13 at 16:33
  • 1
    \$\begingroup\$ @genzo He just means it's not designed to not garble messages when plugged in mid-message. \$\endgroup\$ – DKNguyen Feb 13 at 17:07
  • \$\begingroup\$ to put it another way - a serial transmission without gaps between bytes is designed to be garbled if you switch on mid word. A serial transmission without CRC or other forward error control is designed to not be able to detect the garbling. \$\endgroup\$ – Neil_UK Feb 13 at 22:02
0
\$\begingroup\$

There is also a chance that the system may not detect it as an error. It will simply further sample the idle line and assume stop condition and stop.

The first byte if reported as error, can be cleared in software and the rest of the bytes will be received properly. Hence, in general there will be CRC or error checking mechanism to make sure that the wrongly interpreted messages will not considered.

As soon as there is an idle time of about one complete word.. the system will be ready to receive error free. One word I meant - start bury stop bit and 8 bit of data..

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.