27/317
2 - How does a typical microcontroller work?
2.4 PERIPHERALS
The peripherals are the places where the core, that executes computer code, is in contact with
the real world that is represented by electrical signals.
These signals may just be binary levels that change relatively infrequently, in which case it is
easy to process them using a program. They also may change quickly, too fast for the pro-
gram to handle them without imparing the computing power of the core.
In other cases, the signal is a value that belongs to a continuous range. This type of signal is
called an analog value; by nature, it cannot be processed by the core, and must be converted
into binary data.
An analog value may have several shapes, but it eventually falls into one of two categories:
The data is represented by the time interval between two pulses, or by the frequency of an
AC signal, or by the number of pulses of a pulse train. All these cases can appropriately be
handled by a programmable timer or a UART, for example.
The data is represented by the voltage of an input signal, or the value of a resistor that can
easily be converted into a voltage. This kind of data is handled by the Analog to Digital
Converter.
These considerations justify the presence of specialized peripherals, that include the required
circuitry for processing the data, convert it, etc. so that it is easier to handle for the core. The
less work the core has to do, the more it is available for other tasks. According to the proper-
ties of the signal, the peripheral designed to process it (we say “interface it”) may be anything
from very simple to very sophisticated. We shall give here an idea of some of the most
common peripherals of the ST7, starting with the simplest.
2.4.1 Parallel Input-Outputs
When the data going to or coming from the outside world is made of groups of bits, and if they
can remain stable for a relatively long amount of time (at the scale of an electronic device, that
may be less than one millisecond), parallel input-output ports are the right choice. They only
consist of a set of gates or latches that allow for communications between the inside and the
outside at times that the program chooses. This is used for example to read input switches
and keyboards, and to output signals that drive lamps, motors, etc.
The capabilities of these input-outputs vary greatly from product to product. In some products,
they are unidirectional or bidirectional TTL levels, fixed by hardware. In other products, they
include a latch that can capture the state of the inputs on the transition of an auxiliary strobe
input.
Some manufacturers, including STMicroelectronics, provide configurable input-output pins.
These pins can be set as either inputs, with or without a pull-up resistor, or as an output either