Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

Assignment for Graphics

System
Submitted by: Submitted to:
Name : Mojnu Miah Teacher’s Name: Maruf Al Hossain
Department : CSE 11th DH Lecturer of the Department of CSE
Roll : 21-02-08-001
Topics Name:

USART and HDLC


USART
The USART is used for synchronous and asynchronous serial
communication.

USART = Universal Synchronous/Asynchronous Receiver Transmitter

Asynchronous communication does not use a clock to validate data.

Serial data is transferred one bit at a time.

Asynchronous serial interfaces are cheap, easy to use, and until recently,
very common. USB is well on its way to replace the serial comm ports on
PCs.

The USART communicates in a full-duplex mode (simultaneous xmit, rcv)


Serial frame
format:

Every frame will have at least


-one start bit
-some data bits (5,6,7,8 or
9)
-one stop bit
Parity is
optional
How can two asynchronous devices communicate with each
other?
AVR1 AVR2
16Mhz 16Mhz

There is no known phase relationship between the two AVR boards

How can a receiving board “know” where the center of a bit frame

is? How can it know where the start bit is?

0 1 2 3
start bit
- Need to know how fast the bits are coming (baud rate)
- Need to know where the start bit begins (its falling
edge)
- Then we know when to sample

0 1 2 3
start bit
sample sample sample sample
- The USART uses a 16x internal clock to sample the start
bit.

The incoming data is continuously sampled until a falling edge is


detected. Once detected, the receiver waits 6 clocks to begin sampling.

One clock before the expected center of the start bit, 3 samples are

taken. If 2 or 3 are detected as high, the search for another falling edge is

started.

If at least one sample is low, the start bit is validated. If so, begin
sampling 16 clocks from center of start bit.
- The USART internal clock is set by the UBRR
register.

The internal clock is derived from the


internal CPU clock.

Both transmitter and receiver use the same clock to


operate from. The transmitter is synchronous to
the clock. In coming data to the receiver is not.

The baud rates are not exact power of 2


multiples of the CPU clock, thus baud rate
inaccuracies occur at some settings. This is why
you see some "funny" crystal oscillator
frequencies.
- Error detection
-Parity
-created by an XOR of the data bits
-parity can be even or odd
-P = dn XOR dn-1 XOR dn-2 ........
XOR
-P =d0 dn XOR dn-1 XOR dn-2 ........ XOR d0 XOR
1
•Ifevenwe have a data byte, 0b0010_1101
•and we want odd parity, the parity bit is set to a “one” to make a total
of 9 bits which is an odd number of 1's.... i.e., odd parity
odd

•Thus, the new data byte with parity is:


0b0010_1101 plus the parity bit 1
• parity bit
- Error detection
-Frame error
-a frame error occurs when the receiver is expecting the stop
bit and does not find it.
-also known as a synchronization failure
-the frame (byte) must be resent
stop bit(s)

-Data overrun error


-data was not removed in the receive buffer before
another byte came and overwrote it.
- USART Electrical path
We use the RS-232 standard for communications to a PC. RS-232
specifies an inverted +/- 3 Volt interface.

<= -3 volts is considered a “1” or “mark”


>= +3 volts is considered a “0” or “space”

-3V
+3V
USART and Asynchronous
Communication
- USART RS232 transceiver
-Charge Pump inverter used
to generate negative
voltages.
USART and Asynchronous Communication
- USART Electrical path

The mega128 board uses the MAX232


chip. It has an internal charge pump to
generate the negative and positive
voltages for the RS-232 interface. to port D

The DB9 connector is standard for


mating with a PC serial connector.

The port D interface is shared with the


IR LED I/O devices. They are
to port E
inverted also so that an “space”
signal does not keep the IR LED on
(100mA).
Some useful USART Software Routines:
//**************************************************************
// uart_getc
//Modified to not block indefinately in the case of a lost byte
//
char uart_getc(void) {
uint16_t timer = 0;
while (!(UCSR0A &
(1<<RXC0))) {
timer++;
if(timer >= 16000)
return 0;
} // Wait for byte to
arrive return UDR0;
}
//
*******************************
*******************************
HDLC (High-level Data Link Control)

• What is HDLC?

HDLC (High-level Data Link Control) is a group of


protocol or rules for transmitting data between
network points ( sometimes called nodes).
How does HDLC work?

In HDLC, data is organized into a unit (called a frame) and sent across a
network to a destination that verifies its successful arrival. The HDLC
protocol also manages the flow or pacing at which data is sent.

HDLC is one of the most commonly used internet protocols (IP) in what is
Layer 2 of the industry communication reference model called Open
Systems Interconnection (OSI).

•Layer 1 is the detailed physical level that generates and receives the
electronic signals.
•Layer 3 is the higher level that has knowledge about the network,
including access to router tables that indicate where to forward or send
data.
How is HDLC used in IT networks?

HDLC is based on IBM's synchronous data link control (SDLC) protocol,


which is widely used by IBM's large customer base in mainframe
computing environments. In HDLC, the protocol that is essentially SDLC
is known as Normal Response Mode.

The networking industry has used HDLC to derive several other


standards used today, such as frame relay protocols like the ISDN
protocol stack known as Link Access Procedure Balanced (LAPB). It is
also the basis for the framing mechanism that utilizes Point-to-Point
Protocol (PPP) on synchronous lines used to connect multiple servers to
a WAN (wide area network) internet link, as well as Cisco HDLC framing
techniques that add protocol fields to the HDLC header.
How do HDLC frames work?

• HDLC frames can be transmitted over either asynchronous or synchronous


communication links:

• Synchronous framing. In synchronous frames, data is NRZI (non-return-to-


zero inverted) encoded, meaning that a 0-bit is sent as a change in the
signal, whereas 1-bit is transmitted as no change. In other words, every 0
relays to the receiving modem that it must synchronize its clock. In this
way, frames can be sent via a full-duplex, or half-duplex link.

• Asynchronous framing. On the other hand, in asynchronous


communications, it is not necessary to worry about the bit pattern. Instead,
control-octet transparency is used (otherwise known as bit stuffing). A
control escape octet uses 0x7D values (for example, a '10111110' bit
sequence with the least significant bit first.
HDLC frame types

There are three types of commonly used HDLC frame structures. They are
as follows:

• Information frames (I-frames), which transmit user data from the


computer network layer and incorporate error control information with the
data. I-frames also contain control fields used to define data functions.
• Supervisory frames (S-frames), which transmit error and Flow control
data whenever it becomes impossible to "piggyback" on transmitted data.
For this reason, S-frames don't contain information fields.
• Unnumbered frames (U-frames), which are for all other miscellaneous
purposes, including link management. Some of these contain information
fields, and others do not.
The End

You might also like