How does a serial port work?

Status
Not open for further replies.
I am trying to understand how to transfer data over a serial port. Please take a look at the serial port on the TRS-80 Colour Computer 2: **broken link removed** The one labelled "Coco I/O Serial for printing".

I can understand the ground and data out lines but when does the receiving peripheral know when data is valid? The Commodore 64 has a clock and data line - when sending data, the clock line is pulsed every time the data line is valid, and that tells the peripheral that the bit is valid. With no sync signal, how does the printer know when to read a bit from the data line?
 
Hi Richard,
When no data is being sent the line is at a negative level. (About -5 to -10 volts.) When a character is sent the first thig that happens is the line goes positive for 1 bit period. This indicates to the receiving end that a character is being sent. As the baud rate (Bits per second.) has to be known the receiver now has a time reference and so samples the data bits at about the middle of their time slots and assembles the 7 or 8 data bits (And possibly parity bit.). After the final data bit the transmiting end sends one or two stop bits. So when you configure the UART or USART you have to specify the baud rate, the number of data bits, weather you are using a parity bit and the number of stop bits.

Les.
 
With no sync signal, how does the printer know when to read a bit from the data line?
You are right this is hard to understand. Both ends need to have the "clock frequency" (baud rate) set to the same speed.
As Les said; there is a "start condition", then each clock will get data (7 or 8 times) then parity (if used) then at the end there is a stop condition.
Timing is critical! because there is no clock transmitted. It is assumed.
 
In most cases the Asynchronous mode of transmission is used, there is no need to synchronize the RX/TX data, as opposed to synchronous where there is a common clock signal.
Max.
 
This diagram shows that the data is sampled 4 times per bit. (I think most UARTs sample at 16x)
If the line has been high for one baud time (or more) and you get a falling edge a small "engine" starts thinking.
It delays 0.5 baud time go get to the center of data. If the data is still low thin it is a good start condition.
Data is sampled at the baud rate for the data bits.
There must be a high at the "stop" time.

The two clocks can be off a small amount because at every falling edge at "start" will re-sync the clocks.
If the two clocks are off a little things will work. The start bit will be sampled in the middle but bits 4,5,6,7 will be sampled increasingly more to the right or left of center. (using the diagram) If the two clocks have shifted by less than +/-0.25 baud time then bit-7 will read good. And next "start" will synchronize again.

**broken link removed**
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…