Serial Communication
Serial Communication
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?
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 maximum baud rate is higher than that in the I2C communication system.
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!