Serial Communication

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

SERIAL COMMUNICATION

Parallel connection between the microcontroller and peripherals via input/output ports is the ideal
solution on shorter distances up to several meters. However, in other cases when it is necessary to
establish communication between two devices on longer distances it is not possible to use parallel
connection. Instead, serial communication is used.

Today, most microcontrollers have built in several different systems for serial communication as a
standard equipment. Which of these systems will be used depends on many factors of which the
most important are:

How many devices the microcontroller has to exchange data with? How fast the data exchange has
to be?

What is the distance between devices?

Is it necessary to send and receive data simultaneously?

One of the most important things concerning serial communication is the Protocol which should be
strictly observed. It is a set of rules which must be applied in order that devices can correctly
interpret data they mutually exchange. Fortunately, the microcontroller automatically takes care of
this, so that the work of the programmer/user is reduced to simple write (data to be sent) and read
(received data).

BAUD RATE
The term baud rate is used to denote the number of bits transferred per second [bps]. Note that it
refers to bits, not bytes. It is usually required by the protocol that each byte is transferred along with
several control bits. It means that one byte in serial data stream may consist of 11 bits. For example,
if the baud rate is 300 bps then maximum 37 and minimum 27 bytes may be transferred per second.

The most commonly used serial communication systems are:

I2C (INTER INTEGRATED CIRCUIT)


Inter-integrated circuit is a system for serial data exchange between the microcontrollers and
specialized integrated circuits of a new generation. It is used when the distance between them is
short (receiver and transmitter are usually on the same printed board). Connection is established via
two conductors. One is used for data transfer, the other is used for synchronization (clock signal). As
seen in figure below, one device is always a master. It performs addressing of one slave chip before
communication starts. In this way one microcontroller can communicate with 112 different devices.
Baud rate is usually 100 Kb/sec (standard mode) or 10 Kb/sec (slow baud rate mode). Systems with
the baud rate of 3.4 Mb/sec have recently appeared. The distance between devices which
communicate over an I2C bus is limited to several meters. 

SPI (SERIAL PERIPHERAL INTERFACE BUS)


A serial peripheral interface (SPI) bus is a system for serial communication which uses up to four
conductors, commonly three. One conductor is used for data receiving, one for data sending, one for
synchronization and one alternatively for selecting a device to communicate with. It is a full duplex
connection, which means that data is sent and received simultaneously.

The maximum baud rate is higher than that in the I2C communication system.

UART (UNIVERSAL ASYNCHRONOUS


RECEIVER/TRANSMITTER)
This sort of communication is asynchronous, which means that a special line for transferring clock
signal is not used. In some applications, such as radio connection or infrared waves remote control,
this feature is crucial. Since only one communication line is used, both receiver and transmitter
operate at the same predefined rate in order to maintain necessary synchronization. This is a very
simple way of transferring data since it basically represents the conversion of 8-bit data from parallel
to serial format. Baud rate is not high, up to 1 Mbit/sec.

OSCILLATOR
Even pulses generated by the oscillator enable harmonic and synchronous operation of all circuits
within the microcontroller. The oscillator is usually configured so as to use quartz crystal or ceramic
resonator for frequency stability, but it can also operate as a stand-alone circuit (like RC oscillator). It
is important to say that instructions are not executed at the rate imposed by the oscillator itself, but
several times slower. It happens because each instruction is executed in several steps. In some
microcontrollers, the same number of cycles is needed to execute all instructions, while in others,
the number of cycles is different for different instructions. Accordingly, if the system uses quartz
crystal with a frequency of 20 Mhz, the execution time of an instruction is not 50nS, but 200, 400 or
800 nS, depending on the type of MCU!

You might also like