Page 148 - Programming Microcontrollers in C
P. 148
Input/Output 133
the successive approximation of the analog voltage. This method
works well, and 8- and 10-bit systems are available on
microcontrollers with plus or minus one-half bit accuracy.
Serial Input/Output
Where would the computer be without serial input/output? The
serial system was probably the first direct human interface with any
computer system. It has expanded, and today, relatively low-speed
asynchronous serial interfaces are used for terminal and modem and
network interfaces. High-speed synchronous serial links are used for
all of the above plus inter-computer connections, hardware peripheral
communications, and other types of devices where high-speed, secure
communication is required.
Many microcontrollers have both asynchronous and synchronous
communications peripherals built in. Usually, an asynchronous
interface is called a serial communications interface (SCI) while the
synchronous interface is called a serial peripheral interface (SPI).
Typically SCI systems can communicate at any of the popular
asynchronous serial bit rates. These systems have built-in baud rate
generators, double buffered input and output registers, and all of the
error detection found on a universal asynchronous receiver-transmitter
(UART) chip. These I/O devices can be either polled or interrupt-
driven by the computer portion of the microcontroller.
The SPI is designed to communicate at high speeds with other
microcontrollers or perhaps with hardware devices with a synchronous
serial interface. These devices typically run at megabit per second
rates. Since synchronous systems require a system clock, each
microcontroller SPI can act as either a master or a slave. The main
difference between the master and the slave is which chip generates
the system clock. The master generates the system clock, and the
data are clocked into and out of the slave by the system clock.
Communications with the microcontroller and the SPI can be either
polled (synchronous) or via interrupt controller (asynchronous).
Different Controllers
Not all of these peripheral systems are found on each
microcontroller. It is possible to pick and choose between needs for
the several peripheral systems and select a microcontroller that has