Microcontroller Chapter1
Microcontroller Chapter1
A
R
T
LEARNING
I
MICROCONTROLLERS
1 Introduction to Microcontrollers
2 8051 Microcontrollers
INTRODUCTION
1
TO
MICROCONTROLLERS
Objectives
l Understand the basic building blocks of a microcontroller device in general.
l Know the history and developments in microcontrollers and microprocessors
l Know the terminologies like embedded and external memory devices, CISC
and RISC processors, etc.
l Know some commercial microcontrollers.
1.1 INTRODUCTION
Today, we see many industrial and domestic products like remote controllers, telephone
bill printing machines, automatic power regulators, automatic or semi-automatic washing ma-
chines, microwave ovens, automobiles, engines, indicating and measuring instruments and
similar products. Automation is needed to facilitate the process or mechanism for its operation
and control. Data storage and processing is an integral part of any automatic control system.
The need is to have a device, so called ‘microcontroller’, which allows controlling the timing
and sequencing of these machines and processes. Further, with the help of microcontroller, it
is possible to carry out simple arithmetic and logical operations. Any system that has a remote
controller, almost certainly contains a microcontroller.
" Learning Microcontrollers
Microcontrollers are single-chip microcomputers, more suited for control and automation of
machines and processes. Microcontrollers have central processing unit (CPU), memory, input/
output ports (I/O), timers and counters, analog-to-digital converter (ADC), digital-to-analog
converter (DAC), serial ports, interrupt logic, oscillator circuitry and many more functional
blocks on chip. Figure 1.1 shows a general functional block diagram of a microcontroller. Note
that there may be variations in the functional blocks from device to device and from one
manufacturer to another. All these functional blocks on a single Integrated Circuit (IC), results
into a reduced size of control board, low power consumption, more reliability and ease of
integration within an application design. The usage of microcontrollers not only reduces the
cost of automation, but also provides more flexibility. The designer is little bit relieved from
the complex interfacing of external peripherals like ADC/DACs, etc. and can concentrate on
applications and development aspects. The device can be programmed to make the system
intelligent. This is possible because of the data processing and memory capability of
microcontrollers. Once a typical microcontroller is learnt and practiced, one may wish to go
for other microcontrollers from various makes. Some of the commonly used microcontrollers
are Intel MCS-51, MCS-96, Motorola 68HC12 family, Microchip’s peripheral interface
controller (PIC) family of microcontrollers 16CXX, 17CXX, etc.
Vcc
. ADC
Channels
Timers/Counters Interrupt Logic
Microcontrollers have all the functional blocks which can fulfill the general needs of auto-
mation. Just to get an idea about the use of microcontrollers, consider an example of a
Introduction to Microcontrollers #
temperature indicator as shown in the Fig. 1.2. A single microcontroller IC can directly get the
analog input, say in the range 0–5 V typically, from a temperature sensor and drives LCD
display. Note that there is no need to connect any external memory; the ADC function is also
built inside the single microcontroller IC. The programmer has to write simple software modules
to operate the LCD display and ADC. For example, the ADC operation involves the selection
of ADC channel, generating the start of conversion command, checking the ADC status and
getting the data into memory. The data may be averaged over some samples to improve the
signal-to-noise ratio.
Vcc
LCD Module
Temp: 32°C
mC
TT
Analog Ground
Another important class of processors is the so called ‘Bit-Slice Processors’. The term bit-
slice processor means that the processors can be interconnected to form a processor of any
desired word length. Bit slice processors consist of an ALU typically of 4 or 8 bits1, registers
and control lines. The control lines are connected to each processor slice and all processors
can perform the same operation. An example of a bit-slice processor is AMD’s 2900 series.
The bit-slice microprocessor design has some advantages. The first main advantage is that the
ALUs can be assembled together horizontally to form computers that can handle very large
data at a time. Another advantage of the bit-slice design is that it makes possible the use of
bipolar chip technology that is very fast. Further, the bit-slice design allows users to create
their own instruction sets for their applications. The discussions in this text will be focused
only on the general-purpose microcontrollers and their applications.
1
Bit is the basic unit of digital information. Four bits form a nibble and a byte consists of eight bits.
Introduction to Microcontrollers %
during 1975. PIC family of microcontrollers was introduced around 1985, by Microchip. PIC
uses Harvard architecture, and has a Reduced Instruction Set. In 1978, Intel 8086, a 16-bit
processor, was developed. Followed by this, Motorola introduced a 16-bit microprocessor
68000, and Zilog introduced Z8000, a 16-bit microprocessor. The historical developments in
microprocessor products are listed in Table 1.1.
Table 1.1 Historical Developments in Microprocessors and Microcontrollers
Year Microprocessor/microcontroller Remark
1971 Intel 4004 4-bit microprocessor
1972 Intel 4040 4-bit microprocessor
1974 Intel 8080 8 bit microprocessor
TMS 1000 8 bit microcontroller
1975 Motorola 6800 8 bit microprocessor
1976 MCS-48 8-bit microcontroller
Intel 8085 8-bit microprocessor
1978 8086, Motorola 68000, Zilog Z-8000 16-bit microprocessor
1979
1980 8051 8-bit microcontroller
1982 68010, 6805, Microcontroller
80186, 80188, 80286 16-bit microprocessors
8096 (MCS-96) 16-bit microcontrollers
1984 68020 32-bit microprocessor
1985 80386 32-bit microprocessor
PIC microcontrollers by Microchip 8-bit microcontrollers
1987 Z280 16-bit microprocessor
1989 80386sx, 80486 32-bit microprocessor
1993 Pentium 32-bit microprocessor
1997 Atmel 8-bit AVR family 8-bit RISC microcontrollers
In June 1997, ATMEL 8-bit AVR microcontrollers were introduced which also have reduced
instruction set. Today, we see a number of microcontroller families, from multiple sources and
in many versions. Before discussing more about microcontrollers, let us look at some impor-
tant terms related to microcontrollers.
However, we see normally that devices like 8031 from MCS-51 family need external program
memory interface. These devices are External Memory Devices. In case of 8051/8751, a part
of program execution is possible from the on-chip program memory and rest of the program
execution is from the external memory. Further, there is an option of executing the whole
program only from the external program memory as well. This feature of external memory is
useful, only when the program memory requirement exceeds the one which is available on-
chip. In external memory devices, there is an external address/data bus. Naturally, the number
of pins is more and an additional Printed Circuit Board (PCB) space is needed for memories
and latches, etc.
Programmers want to have fewer, simpler and faster instructions, than the large, complex
and slower CISC instructions. This is, however, at the cost of writing more instructions to
accomplish a task. One advantage of RISC is that because of the more simple instructions,
RISC chips require lesser hardware implementation, which makes them simpler to design and
hence lesser cost of production. And it is always easier to write optimized compilers, because
of a small number of instructions. One example of RISC microcontrollers is the popular PIC
family of microcontrollers by Microchip.
More importance is given to how fast a chip can execute the instructions and how it runs
available or designed software.
CPU CPU
the programs easily. However, the code storage may not be optimal and requires multiple
fetches to form the instruction. Program and data fetches are done using time division
multiplexing which affect the performance. One example of the microcontroller using the Von
Neumann (Princeton) architecture is Motorola 68HC11 microcontroller.
The selection criteria among these are only based on the functional requirements power
supply constraints, available printed circuit board space, pin count and the cost of production.
For a mass production, the designer may go for ROM versions. However, for lesser production,
EPROM version or CPU version with external program memory is suitable. Many a times it is
preferred to go for the EPROM/ROM versions to avoid the external memory connections,
provided the size of the code is less than the size of on-chip program memory. However, one
should note that the EPROM has limited write/erase cycles, typically 1000 write/erase. From
maintenance point of view, one may prefer EPROM or ROM version, because it requires
replacing only a single IC from the board. Further, during the product development, one
spends a lot of intellectual man-hours to design software. So, it is better to use the built-in
‘security fuse’ facility to avoid stealing or unauthorized copying of software. For the
development work, an EPROM eraser and programmer is needed to write or change the code,
along with the testing and debugging tools.
1.8.3 Atmel Microcontrollers
Few devices from the Atmel family are listed in Table 1.3. Mainly we discuss here about the
reprogrammable flash devices. The emphasis is given on 20-pin devices. These devices sup-
port fully static operation from 0 to 24 MHz. The low-frequency operation is very important
when the power consumption is to be kept minimum. For example, in case of the battery
operated instruments, power consumption is crucial. Note, however that the execution speed is
also reduced at low frequencies. Timer-clocking periods are also dependent on the operating
frequency. The power-down modes and IDLE modes can be used to keep the power consumption
to a minimum level. One can select a device with low-voltage operation, typically in the range
2.7–6 V. Atmel 89C1051/2051 devices support this low-voltage operation. For Atmel 89C4051,
this range is 3–6 V.
Learning Microcontrollers
Twenty-pin devices are very much suited when the PCB space available is small, and the
need of I/O lines is fulfilled with 15 I/Os. The precision analog comparator along with timers
can be used for building the counter type ADC. Flash PEROM (Programmable and Erasable
Read Only Memory) is another very useful feature. Ultraviolet EPROM eraser is not needed at
all. The device can be programmed and erased electrically. Atmel 89LV52 is a low-voltage 8K
flash microcontroller compatible with 8032. The operating voltage range is 2.7 V–6 V. For
more details one may refer the Atmel microcontroller product literature. It is also interesting to
see the Atmel AVR family of RISC processors.
1.8.4 PIC Microcontrollers
PIC16CXX and PIC17CXX, 8-bit microcontrollers by Microchip, use CMOS technology. PIC
microcontrollers are popular because of high performance, low cost and small size. It uses
high-speed RISC architecture. PIC 16CXX has only 33 single-word instructions. The operating
frequency typically for 16CXX parts ranges from DC to 20 MHz. It is possible to add external
program memory, up to 64K words. The PIC 17C42 has a number of counter/timer resources
and I/O handling capabilities. 16C71 has built in 8-bit ADC with 4 channels.
To have a 10-bit ADC with 12 channels, one can go for 17C752 device. PIC microcontroller
devices are briefly described in Table 1.4. There are many more devices by Microchip in many
versions, which are not listed in the table. General features include, timers, watchdog timers,
embedded ADC, extended instruction/data memory, serial communication, pulse width
modulated (PWM) outputs, and ROM, EPROM and EEPROM memories.
Introduction to Microcontrollers !
Summary
In this chapter, various microcontroller building blocks have been discussed
and the reader is introduced to some of the commercially available
microcontroller devices. Terminologies like CISC and RISC processors,
embedded and external memory devices have been discussed. A historical
background of microprocessors has been given to understand how the
microcontroller development has taken place. A comparison of various devices
and their selection criteria is a part of practice; however, efforts have been
made to introduce the basic concepts behind this process. The readers may
go through the manufacturer data sheets and product information in more
detail before working on their own designs. This is because a large number
of devices with different versions are available in market. The following hands-
on exercises will help in keeping the necessary information ready, at the time
of designing a microcontroller-based product.
Review Questions
1.1 What do you mean by the term embedded controllers and external memory devices?
1.2 Discuss the advantages of microcontrollers over microprocessors in control applications.
1.3 What are RISC and CISC processors?
1.4 Discuss the criteria for selecting a microcontroller device.
1.5 How do you distinguish between 8-bit and 16-bit microcontrollers?
1.6 Discuss the advantages and disadvantages of Harvard and Von Neumann architectures.
1.7 Why would one may possibly go for microcontrollers other than the popular 8051?
" Learning Microcontrollers
1.8 What are the various issues while selecting a microcontroller having RISC philosophy?
1.9 When a microcontroller like PIC by Microchip, which is a RISC processor, is there;
why and in which situation one should go for CISC processor like 8051?
1.10 In case of Harvard architecture, why there is no need for multiplexing the address and
data buses? How and why the address and data buses may have different widths? If this
is true, why is it difficult to have external memory expansion in case of these devices?
1.11 Out of the microcontrollers discussed in this chapter, which microcontrollers use Harvard
architecture? Also state whether they are RISC processors.
1.12 List the factors to be considered while going for ROM, EPROM, EEPROM, and Flash
memory versions of microcontroller devices.
1.13 Why is it not advisable to use dynamic RAM with microcontrollers?
1.14 What are the advantages and disadvantages of using a battery backup RAM?
1.15 List the domestic applications where microcontrollers would be possibly useful or do
better?
Hands-on Exercises
1.1 Collect the data sheets of the microcontroller devices available in market and compare
them with respect to their salient features and specifications. For this you may refer some
of the web sites given below:
Intel: www.intel.com
Atmel: www.atmel.com
Siemens: www.sci.siemens.com
1.2 Collect the information about the development tools available for the various
microcontroller devices.
1.3 Get the information about the EPROM programmer and EPROM eraser. See the devices
supported by the programmer.