Serial Communication: Implementation and Types, Study notes of System Programming

The implementation of a sender and receiver program for serial communication and discusses the advantages and disadvantages of serial communication, as well as the differences between synchronous and asynchronous serial communication. The document also covers the use of a universal asynchronous receiver transmitter (uart) and the rs-232c standard.

Typology: Study notes

2011/2012

Uploaded on 08/07/2012

anishay
anishay 🇮🇳

4.2

(25)

118 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture # 13
Program implementing the described protocol
int i= 0; char Buf[1024];
while (1)
{ch = Buf [i];
if ((inport((*lpt) + 1)& 0x80) == 0)
{ch = Buf [i];
ch = ch& 0xEF;
while((inport((*lpt) + 1) &0x80) == 0);
}
else
{ch = Buf [i];
ch = ch>> 4;
ch = ch | 0x10;
outport (*lpt, ch);
i++;
while((inport((*lpt) + 1) &0x80) == 80);
}
}
This is the sender program. This program if find the BUSY bit clear sends the low nibble
but turns the D4 bit to 0 before sending. Similarly it right shifts the byte 4 times sets the
D4 bit and then sends the high nibble and waits for acknowledgment until the BUSY is
cleared.
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Serial Communication: Implementation and Types and more Study notes System Programming in PDF only on Docsity!

Lecture # 13

Program implementing the described protocol

int i= 0; char Buf[1024]; while (1) { ch = Buf [i]; if ((inport((lpt) + 1)& 0x80) == 0) { ch = Buf [i]; ch = ch & 0xEF; while((inport((lpt) + 1) &0x80) == 0); } else { ch = Buf [i]; ch = ch >> 4; ch = ch | 0x10; outport (lpt, ch); i++; while((inport((lpt) + 1) &0x80) == 80); } }**

This is the sender program. This program if find the BUSY bit clear sends the low nibble

but turns the D4 bit to 0 before sending. Similarly it right shifts the byte 4 times sets the

D4 bit and then sends the high nibble and waits for acknowledgment until the BUSY is

cleared.

int i;

while (1)

{ if ((inport(*lpt + 1)& 0x80) == 0x80)

{ x = inport ((*lpt) + 1);

x = x >> 3;

x = x & 0x0F;

outport((*lpt), x);

while((inport(*lpt + 1) &0x80) == 0x80);

else

{ y = inport ((*lpt) + 1);

y = y << 1;

temp = y;

y = y & 0xF0; //instruction added

y = y | x;

temp = temp >> 3; temp = temp | 0x10; i++; outport (lpt, temp); Buf [i] = y; while((inport((lpt) + 1) &0x80) == 0); } }**

This is receiver program. If the BUSY bit is clear it receives the low nibble and stores it

in x. Similarly if the BUSY bit is 0 it receives the high nibble and concatenates the botth

nibble to form a byte.

In case of synchronous communication as shown in the slide a timing signal is required to

identify the start and end of a bit.

  • Sampling may be edge triggered.
  • Special line may be required for

timing signal (requires another line).

  • Or the timing signal may be encoded

within the original signal (requires

double the bandwidth).

Synchronous Communication

Asynchronous Communication

  • Does not use make use of timing

signal.

  • Each byte (word) needs to

encapsulated in start and end bit.

Asynchronous Communication

In case of asynchronous communication no timing signal is required but each byte needs

to be encapsulated to know the end and start of a byte.

UART (Universal Asynchronous Receiver Transmitter)

Serial Communication using a UART

5 – 8 bit

Start bit 1, 1.5, 2 Stop bit

Start bit of next byte

Parity bit

  • 1.5 Stop bit

The UART is a device used for asynchronous communications. UART is capable o

encapsulating a byte that might be 5,6,7 or 8 bits wide in start and stop bits. Moreover it

can attach an extra parity bit with the data for error detection. The width of stop bits may

also vary.

Bit rate = 9600

A bit is sampled after = 1/

-- But start and end bits of a particular

Byte cannot be recognized.

-- So 1.5 stop bit (high) is used to

encapsulate a byte. A low start bit at

the start of Byte is used to identify the

start of a Byte.

Sampling Rate

RS – 232C Standard

  • Standard for physical dimensions of the

connectors.

PC

(DTE)

Modem

RS – 232C Cable

Connected via serial port

(DCE)

RS232C is a standard for physical dimension of the connector interconnecting a

DTE(Data terminal equipment) and DCE (Data communication equipment).

RS – 232C Connectors and Signals DB25 (25 pin connector)

(^1) 25 pin connector on PC

2

9

7

8

4

5

6

10

11

12

13

3

25 24 23 22 21 20 19 18 17 16 15 14

RI CD DTR GND DSR CTS RTS RD T X D

The pin outs of the DB25 connector used with RS232C is shown in the slide above.