رفتن به مطلب

atmel microcontroller : SERIAL COMMUNICATIONS in atmega


am in

ارسال های توصیه شده

Microcontrollers must often exchange data with other microcontrollers or peripheral devices.Data

may be exchanged by using parallel or serial techniques.With parallel techniques, an entire byte of

data is typically sent simultaneously from the transmitting device to the receiver device. Although

this is efficient from a time point of view, it requires eight separate lines for the data transfer .

In serial transmission, a byte of data is sent a single bit at a time. Once 8 bits have been

received at the receiver, the data byte is reconstructed.Although this is inefficient froma time point

of view, it only requires a line (or two) to transmit the data.

The ATmega16 is equipped with a host of different serial communication subsystems,

including the serial USART, SPI, and TWI. What all of these systems have in common is the

serial transmission of data. Before discussing the different serial communication features aboard the

ATmega16, we review serial communication terminology.

SERIAL COMMUNICATION TERMINOLOGY

Asynchronous versus Synchronous Serial Transmission

In serial communications, the transmitting and receiving device must be synchronized to one

another and use a common data rate and protocol. Synchronization allows both the transmitter and

receiver to be expecting data transmission/reception at the same time. There are two basicmethods

of maintaining ‘‘sync’’ between the transmitter and receiver: asynchronous and synchronous.

In an asynchronous serial communication system, such as theUSARTaboard theATmega16,

framing bits are used at the beginning and end of a data byte. These framing bits alert the receiver

that an incoming data byte has arrived and also signals the completion of the data byte reception.

The data rate for an asynchronous serial system is typically much slower than the synchronous

system, but it only requires a single wire between the transmitter and receiver.

A synchronous serial communication system maintains ‘‘sync’’ between the transmitter and

receiver by employing a common clock between the two devices.Data bits are sent and received on

the edge of the clock. This allows data transfer rates higher than with asynchronous techniques but

requires two lines, data and clock, to connect the receiver and transmitter.

Baud Rate

Data transmission rates are typically specified as a baud or bits per second rate. For example, 9600

baud indicates data are being transferred at 9600 bits per second.

Full Duplex

Often, serial communication systemsmust both transmit and receive data.To do both transmission

and reception simultaneously requires separate hardware for transmission and reception. A single

duplex system has a single complement of hardware that must be switched from transmission

to reception configuration. A full duplex serial communication system has separate hardware for

transmission and reception.

Nonreturn to Zero Coding Format

There aremany different coding standards used within serial communications.The important point

is the transmitter and receiver must use a common coding standard so data may be interpreted

correctly at the receiving end. The Atmel ATmega16 uses a nonreturn to zero coding standard.

In nonreturn to zero, coding a logic 1 is signaled by a logic high during the entire time slot allocated

for a single bit, whereas a logic 0 is signaled by a logic low during the entire time slot allocated for

a single bit.

The RS-232Communication Protocol

When serial transmission occurs over a long distance, additional techniques may be used to ensure

data integrity. Over long distances, logic levels degrade and may be corrupted by noise. At the

receiving end, it is difficult to discern a logic high from a logic low. The RS-232 standard has

been around for some time. With the RS-232 standard (EIA-232), a logic 1 is represented with

a ?12-VDC level, whereas a logic 0 is represented by a +12-VDC level. Chips are commonly

available (e.g., MAX232) that convert the 5- and 0-V output levels from a transmitter to RS-232-

compatible levels and convert back to 5- and 0-V levels at the receiver. The RS-232 standard also

specifies other features for this communication protocol.

Parity

To further enhance data integrity during transmission, parity techniques may be used. Parity is an

additional bit (or bits) that may be transmitted with the data byte. The ATmega16 uses a single

parity bit. With a single parity bit, a single-bit error may be detected. Parity may be even or odd.

In even parity, the parity bit is set to 1 or 0, such that the number of 1’s in the data byte including

the parity bit is even. In odd parity, the parity bit is set to 1 or 0, such that the number of 1’s

in the data byte including the parity bit is odd. At the receiver, the number of bits within a data

byte including the parity bit are counted to ensure that parity has not changed, indicating an error,

during transmission.

American StandardCode for Information Interchange

The American Standard Code for Information Interchange (ASCII) is a standardized seven-bit

method of encoding alphanumeric data. It has been in use for many decades, so some of the

characters and actions listed in the ASCII table are not in common use today. However, ASCII

is still the most common method of encoding alphanumeric data. The ASCII code is provided

in Figure 2.1. For example, the capital letter ‘‘G’’ is encoded in ASCII as 0×47. The ‘‘0x’’ symbol

indicates the hexadecimal number representation. Unicode is the international counterpart of

ASCII. It provides standardized 16-bit encoding format for the written languages of the world.

ASCII is a subset of Unicode. The interested reader is referred to the Unicode home page website

at

برای مشاهده این محتوا لطفاً ثبت نام کنید یا وارد شوید.
for additional information on this standardized encoding format.

لینک به دیدگاه
×
×
  • اضافه کردن...