Author Topic: Asynchronous in protocol  (Read 1895 times)

0 Members and 2 Guests are viewing this topic.

Offline Kittu20Topic starter

  • Regular Contributor
  • *
  • Posts: 115
  • Country: in
Asynchronous in protocol
« on: January 22, 2024, 12:48:29 pm »
Hi everyone,

I'm trying to understand what it means by asynchronous in protocols. I understand that I2C and SPI are synchronous, meaning the receiver knows when to read data based on the clock signal. However, UART is asynchronous. How does recover know when to read data

Could someone explain on what exactly is meant by asynchronous in this context?

Thanks!
 

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4026
  • Country: nl
Re: Asynchronous in protocol
« Reply #1 on: January 22, 2024, 01:02:41 pm »
You already said it yourself. The synchronous ones use a clock signal to let the other side know when to read or write the data.

In the asynchronous systems there is no clear clock signal and it has to be retrieved from the data. For this line signals are used. In case of the UART there is a start and a stop bit clearly marking the data. Also normally there is an agreement between both sides what bit rate is used. When the receiver sees a start bit it makes sure to align the internal clock such that it samples in the middle of the data bits.

A lot of the UART peripherals use oversampling techniques to make this work reliable.

Offline Andy Chee

  • Frequent Contributor
  • **
  • Posts: 814
  • Country: au
Re: Asynchronous in protocol
« Reply #2 on: January 22, 2024, 01:13:58 pm »
Asycnhronous means the transmitter clock and receiver clock are not synchronised.

For example, for a theoretical 9600 baud rate transmission, the transmitter clock might be 9605.01 baud and the receiver clock might be 9598.94 baud.  The differences are due to imperfect crystal oscillators in the transmitter and receiver.

For the most common 1 start bit, 8 data bits, 1 stop bit, serial data format, you can tolerate maybe 2% baud rate difference before communication is impossible.
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4272
  • Country: nz
Re: Asynchronous in protocol
« Reply #3 on: January 22, 2024, 01:29:22 pm »
For the most common 1 start bit, 8 data bits, 1 stop bit, serial data format, you can tolerate maybe 2% baud rate difference before communication is impossible.

It seems to me that if you're going to re-synchronise after every 10 bits then a 5% difference between sender and receiver should (just) work.
 

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4026
  • Country: nl
Re: Asynchronous in protocol
« Reply #4 on: January 22, 2024, 01:42:15 pm »
I seem to remember from back in the 8051 days that depending on the xtal frequency and the divider setting specific baud rates could be made with a certain amount of error and still work reliably with other systems with different xtal frequencies, but I can't recall the absolute error with which it still worked.

Here is an article about it https://www.allaboutcircuits.com/technical-articles/the-uart-baud-rate-clock-how-accurate-does-it-need-to-be/

Online dietert1

  • Super Contributor
  • ***
  • Posts: 2257
  • Country: br
    • CADT Homepage
Re: Asynchronous in protocol
« Reply #5 on: January 22, 2024, 01:48:54 pm »
Asycnhronous means the transmitter clock and receiver clock are not synchronised.

For example, for a theoretical 9600 baud rate transmission, the transmitter clock might be 9605.01 baud and the receiver clock might be 9598.94 baud.  The differences are due to imperfect crystal oscillators in the transmitter and receiver.

For the most common 1 start bit, 8 data bits, 1 stop bit, serial data format, you can tolerate maybe 2% baud rate difference before communication is impossible.
As a first remark: In asynchronous communication the receiver uses its own clock to sample the incoming data. Making sense of those data depends on prior agreements on the data format.
In synchronous communication the receiver gets and uses the transmitter clock to sample the incoming data.

Regards, Dieter
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 9003
  • Country: gb
Re: Asynchronous in protocol
« Reply #6 on: January 22, 2024, 01:58:22 pm »
For the most common 1 start bit, 8 data bits, 1 stop bit, serial data format, you can tolerate maybe 2% baud rate difference before communication is impossible.

It seems to me that if you're going to re-synchronise after every 10 bits then a 5% difference between sender and receiver should (just) work.
The error you can tolerate varies a lot with the nature of the transmission and receiver sides. Quite a few sources do not have an accurate 1:1 mark:space ratio. A lot of low speed modems (V.21, V.,23. Bell 103) are like this. If the receiver is using a x16 clock to sample the incoming signal, which is the commonest form of UART, that gives you a 6.25% ambiguity in catching the edges. So now other factors can't add up to too much, or the last couple of bits of each byte will get pretty flaky. 2% is usually about the most mismatch you can tolerate between the source and sink side clocks. There are UART communication channels which can tolerate >8% without error, but there are unusual designs.

 

Offline woofy

  • Frequent Contributor
  • **
  • Posts: 348
  • Country: gb
    • Woofys Place
Re: Asynchronous in protocol
« Reply #7 on: January 22, 2024, 02:41:14 pm »
On a 10bit frame (start + 8 data + stop) the leading trailing edge of the last bit is 5% away from the center of the bit. You have to stay inside of that. If if the Tx is 5% low and the Rx 5% high then it will not work. In practice 2% is a sensible max error. Some Microchip PIC's have a gotcha here. They will quote a headline 1% accuracy on the internal osc, but look closer and its actually 2% at best and 5% at temperature extremes (PIC18F24Q10). For that reason if I need UARTs then I put a crystal on the MCU and forget about it..

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4272
  • Country: nz
Re: Asynchronous in protocol
« Reply #8 on: January 23, 2024, 12:04:03 am »
On a 10bit frame (start + 8 data + stop) the leading trailing edge of the last bit is 5% away from the center of the bit. You have to stay inside of that. If if the Tx is 5% low and the Rx 5% high then it will not work. In practice 2% is a sensible max error.

I agree with that.

The person I was replying to said a 2% difference between tx and rx, not opposite 2% errors in each one.
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 9003
  • Country: gb
Re: Asynchronous in protocol
« Reply #9 on: January 23, 2024, 02:20:24 pm »
On a 10bit frame (start + 8 data + stop) the leading trailing edge of the last bit is 5% away from the center of the bit. You have to stay inside of that. If if the Tx is 5% low and the Rx 5% high then it will not work. In practice 2% is a sensible max error. Some Microchip PIC's have a gotcha here. They will quote a headline 1% accuracy on the internal osc, but look closer and its actually 2% at best and 5% at temperature extremes (PIC18F24Q10). For that reason if I need UARTs then I put a crystal on the MCU and forget about it..
A lot of serial comms with PCs used to have a systemic error, which I think was over 1%. Some IC maker figured that dividing an available clock by a simple ratio got them pretty close to the normal UART bit rate sequence - 300, 600... 115200 - and it was good enough. I can't remember which clock they used, and the exact error they ended up with, but that was a very widely used design. I think that was an ISA specific issue, but in the 1990s it was pretty much the norm.
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1661
  • Country: nl
Re: Asynchronous in protocol
« Reply #10 on: January 23, 2024, 07:05:33 pm »
Hi everyone,

I'm trying to understand what it means by asynchronous in protocols. I understand that I2C and SPI are synchronous, meaning the receiver knows when to read data based on the clock signal. However, UART is asynchronous. How does recover know when to read data

Could someone explain on what exactly is meant by asynchronous in this context?

Thanks!

Both ends need to be in agreement on the baud rate set. Then, the receiver just need to know when to start sampling. This process is called synchronization. Or in more analog terms: the baud rate sets the frequency, and then synchronization locks in the phase.
The frequency is "by design" (or needs to be set by user), while the phase needs to be resolved in the hardware during "runtime"

Many protocols only lock in the phase at the start of a frame. For UART this is done by the start bit. The receiver knows (expects) a certain shape of an UART frame, and its statemachine can then decide when to sample the line. However, the exact implementation details can vary per UART.. for example, you could make a functional UART by sampling exactly in the middle of the (presumed) bit period, however, many UARTs use oversampling with e.g. majority vote.
But because the UART only synchronizes its statemachine at the start bit, any frequency error will accumulate over time and hence there are some tolerances on the frequency errors (of both sides). More sophicated protocols are possible, on of which is UART "auto baud" mechanisms. These include sending a specific character which allows the start bit duration to be measured, so the UART receiver can "automatically" set up its timer registers accordingly. However, the characteristics of this "auto baud" training requires that the user protocol to include that, which is why I don't think its really used that often..

Note that an UART uses a start bit for each individual character(frame) sent. This lowers the time window at which a correct sync is needed to only 10-10.5 bits or so, and hence, quite a poor oscillator tolerance could (theoretically) be supported. Again, may vary per implementation, though.
However if you look at other asynchronous protocols such as CAN, USB HS or RF comms you'll find much stricter oscillator requirements. Some protocols that need to support sending very large frames also have more techniques to maintain synchronization, such as tricks with line encoding (think differential manchester) or using DLLs, PLLs or timing error detectors (popular for SDR).
« Last Edit: January 23, 2024, 07:07:19 pm by hans »
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3809
  • Country: us
Re: Asynchronous in protocol
« Reply #11 on: January 23, 2024, 08:14:21 pm »

A lot of serial comms with PCs used to have a systemic error, which I think was over 1%. Some IC maker figured that dividing an available clock by a simple ratio got them pretty close to the normal UART bit rate sequence - 300, 600... 115200 - and it was good enough. I can't remember which clock they used, and the exact error they ended up with, but that was a very widely used design. I think that was an ISA specific issue, but in the 1990s it was pretty much the norm.

It still an issue with microcontrollers today.  If you have a microcontroller with a 42 MHz bus clock, and 16x oversampling, the closest you can get to 115200 is something like 114100, about 1% low.  Talk to someone else with a clock that works out a bit too high and you can eat up a significant margin of your clock tolerance before you even get started.
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1691
  • Country: au
Re: Asynchronous in protocol
« Reply #12 on: January 24, 2024, 02:08:03 am »
A lot of serial comms with PCs used to have a systemic error, which I think was over 1%. Some IC maker figured that dividing an available clock by a simple ratio got them pretty close to the normal UART bit rate sequence - 300, 600... 115200 - and it was good enough. I can't remember which clock they used, and the exact error they ended up with, but that was a very widely used design. I think that was an ISA specific issue, but in the 1990s it was pretty much the norm.
The original PCs used 8250 UART and 1.8432MHz crystals, so they were very precise on bit-timing.

When first USB-UARTS came along with the retiring of 'classic serial ports' on PCs they used 6/12MHz crystals for USB, and those baud speeds became 'exactly incorrect' and 115200 is 115384.6154
- but at least 'two the same', would match.

Then vendors got better at on chip oscillators, and using the trim in those oscillators to lock to the USB frame.
The newest FS-USB-UARTS now have relaxed clock specs, as they use crystal-less digital locked loops, so those have errors of up to 0.5%, typically ~0.3%.
 

 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4272
  • Country: nz
Re: Asynchronous in protocol
« Reply #13 on: January 24, 2024, 05:30:06 am »
When first USB-UARTS came along with the retiring of 'classic serial ports' on PCs they used 6/12MHz crystals for USB, and those baud speeds became 'exactly incorrect' and 115200 is 115384.6154
- but at least 'two the same', would match.

Which is 0.16% error, which is perfectly fine.

Quote
Then vendors got better at on chip oscillators, and using the trim in those oscillators to lock to the USB frame.
The newest FS-USB-UARTS now have relaxed clock specs, as they use crystal-less digital locked loops, so those have errors of up to 0.5%, typically ~0.3%.

Which is more error.
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 9003
  • Country: gb
Re: Asynchronous in protocol
« Reply #14 on: January 24, 2024, 02:35:48 pm »
A lot of serial comms with PCs used to have a systemic error, which I think was over 1%. Some IC maker figured that dividing an available clock by a simple ratio got them pretty close to the normal UART bit rate sequence - 300, 600... 115200 - and it was good enough. I can't remember which clock they used, and the exact error they ended up with, but that was a very widely used design. I think that was an ISA specific issue, but in the 1990s it was pretty much the norm.
The original PCs used 8250 UART and 1.8432MHz crystals, so they were very precise on bit-timing.

When first USB-UARTS came along with the retiring of 'classic serial ports' on PCs they used 6/12MHz crystals for USB, and those baud speeds became 'exactly incorrect' and 115200 is 115384.6154
- but at least 'two the same', would match.

Then vendors got better at on chip oscillators, and using the trim in those oscillators to lock to the USB frame.
The newest FS-USB-UARTS now have relaxed clock specs, as they use crystal-less digital locked loops, so those have errors of up to 0.5%, typically ~0.3%.
The very original PCs used 8250 chips and then 16450 chips. Then people like Chips and Technologies made optimised chip sets for PC motherboards, and people made 16450 workalikes for peripheral cards. If you look through those things you will find some interesting shortcuts. One made UARTs run quite a bit off the right frequency. More than the errors you get with USB UARTs. If you try the UART in the ITE chips on many modern motherboards you might find they still use whatever that shortcut was.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf