Sample Chapter
Sample Chapter
INTRODUCTION
TO COMPUTER,
MICROPROCESSOR AND
MICROCONTROLLER
Learning Objectives
After you have completed this chapter, you should be able to
Dene or explain the following terms: Computer, CPU, Memory, Input unit,
Output unit, Bus, RAM and ROM
Explain the difference between microprocessor and microcontroller
Compare features of commercial microcontrollers
Explain the difference between Von Neumann (Princeton) architecture and
Harvard architecture
Explain the difference between RISC and CISC machines
Explain the difference between machine language, assembly language and
high level language programming of a computer
Explain embedded system architecture, design challenges and embedded
operating system
1.1
WHAT IS A COMPUTER?
A computer is a multipurpose programmable machine that reads binary instructions from its memory,
accepts binary data as input, processes data according to those instructions and provides result as output.
It is a programmable device, made up of hardware and software. The various components of the computer
are called hardware. A set of instructions written for the computer to solve a specic task is called a
program and a collection of programs is called software. The computer hardware consists of four main
components:
1. Central Processing Unit (CPU), which acts as the computers brain.
2. Input unit, through which program and data can be entered into the computer.
3. Output unit, from which the results of computation can be displayed or viewed and
4. Memory, in which the programs and data are stored. Figure 1.1 shows a simple block diagram of a
computer.
The processor communicates with the memory and input/output devices using three sets of lines called
busesaddress bus, data bus, and control bus. The bus is a communication path between the processor and
the peripherals.
Register File
The register le consists of one or more registers. A register is a storage location in the
CPU. It is used to hold data and/or a memory address during execution of an instruction.
Arithmetic Logic Unit The arithmetic logic unit is the computers numerical calculator and logical
operation evaluator. Under command from the control unit, it receives information from the memory. It
analyses and rearranges the data and carries out the sequence of arithmetic and logical operations to
accomplish the desired job.
Control Unit It controls and coordinates all the activities in the computer. It decodes the instructions and
generates the necessary control signals for the execution of instructions. The system clock synchronises the
activities of the control unit. All CPU activities are measured by clock cycles. The control unit also contains
a register called the Program Counter (PC), which contains the memory address of the next instruction to
be executed.
1.1.2 Memory
The memory is a place where programs and data are stored. It is a storage device that stores instructions,
data and intermediate results and provides that information to the other units of the computer. A computer
contains Semiconductor, Magnetic or Optical memory. Semiconductor memory has been discussed in this
chapter. Figure 1.2 shows the classication of semiconductor memory into two major typesRandom
Access Memory (RAM) and Read Only Memory (ROM).
Random Access Memory Random access memory, popularly known as user memory, is used to store
user program and data. It is also known as read/write (R/W) memory because it is equivalent to a group of
addressable registersyou can either read the stored contents of memory location or write new contents
into the memory location. The R/W memory is volatile, which means that when the power is turned off, the
contents are lost. To communicate with the memory, the CPU should be able to
Select the memory chip
Select the register in the memory chip
Read from or write into the register
Model of a typical read/write memory is shown in Fig. 1.3(a). The gure shows the chip select as CS,
write signal as WR and read signal as RD these are active low signals indicated by the bar. They help
to select RAM and perform write and read operations. A ip-op that can store one binary bit is called a
memory cell. If more than one ip op are grouped together, it is called a register.
In Fig. 1.3(b), the random access memory contains eight registers; each register contains eight memory
cells and are arranged in a sequence. Here, the size of the memory is 8 8 bits or 8 bytes. To write into or
read from any one of the registers, a specic register has to be selected. This is achieved by using a 3 to 8
decoder. Three address lines A2, A1 and A0 are required for the decoder. These input lines can have eight
different bits combination (000, 001, 010, 011, 100, 101, 110, 111), and each combination can select one of
the registers.
Registers are made up of ip-ops and it stores bit as a voltage. Dynamic memory uses one MOS
transistor and one capacitor to store one bit of information in the form of electrical charge. Static memories
are designed to store binary information without needing periodic refreshes and require one ip-op to store
one bit of information (four to six transistors are needed to store one bit of information). Hence, it requires
the use of more complicated circuitry for each bit. The advantage of dynamic memory is that a large
number of transistor gates can be placed on the memory chip; thus it has high density and is faster than
static memory. The disadvantage is that the charge (bit information) leaks and hence, it requires periodic
refreshing, i.e. information needs to be read and written again after every few milliseconds.
Read Only Memory The read only memory is the simplest kind of memory. It is equivalent to a group
of registers and each store a word permanently. It is a nonvolatile memory which means that it retains the
stored information even if the power is turned off. By applying control signal, we can read the contents of
any memory location and if the processor attempts to write data to a ROM location, ROM will not accept
the data. The model of a typical read only memory is shown in Fig. 1.4(a). The concept of ROM can be
explained with the diodes arranged in a matrix format, as shown in Fig. 1.4(b). The horizontal lines are
connected to the vertical lines using diodes to store 1. The presence of diode stores 1 and the absence of
diode stores 0. When a register is selected, the voltage of that line goes high, and the output lines, where
the diodes are connected also go high. When the memory register 010 is selected, the data byte 00000110
(06H) can be read at the data lines.
Two types of ROM are presently available, permanent ROM and erasable ROM. Permanent ROM
includes two types of memory, Masked read only memory and Programmed read only memory.
Masked Read Only Memory (MROM) MROM is a type of ROM where binary instruction/data are
stored during its fabrication. The semiconductor manufacturer places binary instruction/data in the memory
according to the request of the customer. MROM is used to hold microcontroller application program and
constant data.
Programmed Read Only Memory (PROM) PROM is a type of read only memory that can be
programmed in the eld using a device called PROM programmer and here the programming is permanent.
In other words, the stored contents cannot be erased.
Erasable memory includes three types of memoryEPROM, EEPROM, and Flash memory.
Erasable Programmable Read Only Memory (EPROM) The information stored in this memory is
semi-permanent. Data is stored with PROM programmer. Subsequently, all the information can be erased
by exposing the memory to ultraviolet light through a quartz window installed on top of the EPROM chip.
It can then be reprogrammed.
computer. The user can enter instructions and data through an input device like a keyboard. Analog to
digital converters, and switches can also be used as input devices.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
1.2
WHAT IS A MICROPROCESSOR?
In the late 1960s, the CPU was designed with discrete logic gates. As semiconductor technology advanced,
it was possible to fabricate more than thousand gates on a single silicon chipthis came to be known as
Large-scale integration. As technology moved from Small-scale Integration to Large-scale Integration, it
became possible to build a whole CPU with its related timing functions on a single chip. This came to be
known as Microprocessor. A computer that is designed using a microprocessor as its CPU, is known as a
Microcomputer.
Intel Corporation announced the rst 4 bit microprocessor 4004 in 1971. The number of bits refer
to the number of binary digits that the microprocessor can manipulate in one operation. Soon after this,
Intel developed an 8 bit microprocessor 8080 in 1974. The 8085 microprocessor that followed 8080, had
few more additional features compared to 8080 architecture. The instruction sets of 8080 and 8085 are
practically the same. The 8085 microprocessor has an 8 bit data bus, so it can read data from or write data
to memory or I/O ports only 8 bit at a time. It has a 16 bit address bus, so it can address any one of 216 or
65,536 memory locations. It operates with 3MHz clock signal. The limitations of 8085 microprocessor are
Because of these limitations, Intel Corporation announced the rst 16 bit microprocessor 8086 in 1974.
The 8086 microprocessor has 16 bit data bus and 20 bit address bus. It can read or write data to memory
or I/O ports either 16 bit or 8 bit at a time and it can address any one of 1,048,576 (220) memory locations.
Subsequently, Intel developed 16 bit processors such as 8088, 80186, 80188 and 80286. The Intel 8088
has the same instruction set and arithmetic unit as the 8086. It has 8 bit data bus and 20 bit address bus
and can read or write data to memory or I/O devices only 8 bit of data at a time. 80186 and 80188 are
an improved version of 8086 and 8088 respectively. Both the processors have a few additional instruction
sets compared to 8086 instruction set. 80286 is an improved version of 80186. It is designed to be used
as CPU in multitasking computers. It operates in real and virtual addressing mode. Later, in 1985, Intel
developed 32 bit microprocessor 80386. The 80386 can address directly up to 4 gigabytes of memory.
Intels second generation of 32 bit microprocessor 80486 was available in the year 1989. Intel introduced
a third generation 80586 (Pentium processor) in 1998. Motorola, Zilog, etc. also developed 8 bit, 16 bit
and 32 bit Microprocessors. Microprocessors have been widely used after their invention. However, the
following limitations of the microprocessor led to the invention of the microcontroller.
A microprocessor requires external memory to execute a program.
A microprocessor cannot be directly interfaced with I/O devices. Peripheral chips are needed to
interface I/O devices.
1.
2.
3.
4.
5.
1.3
The 8085 microprocessor has ___________ bit data bus and ___________ bit address bus.
List the limitations of the 8085 microprocessor.
The 8088 microprocessor has ___________ bit data bus and ___________ bit address bus.
The 80386 is a ___________ bit microprocessor.
List the limitations of microprocessor.
WHAT IS A MICROCONTROLLER?
As technology moved from LSI to VLSI, it became possible to build the microprocessor, memory and I/O
devices on a single chip. This came to be known as the Microcontroller.
A microcontroller contains a microprocessor and also one or more of the following components.
Memory
Analog to Digital (A/D) converter
Digital to Analog (D/A) converter
Parallel I/O interface
Serial I/O interface
Timers and Counters
Figure 1.5 shows the block diagram of a typical microcontroller, which is a true computer on-chip. The
rst 4 bit microcontroller was developed by different companies like Hitachi, National, Toshiba, etc. Soon
after this, 8 bit microcontrollers were developed by Intel, Motorola, Zilog, Philips, Microchip technology, etc.
1.3.1
Applications of Microcontroller
Microcontrollers have been widely used in home appliances such as refrigerators, washing machines and
microwave ovens. It is used in displays, printers, keyboards, modems, charge card phones and also in
automobile engines, etc. as controllers.
TABLE 1.1
Device
Register
Memory
On-chip
(bytes)
On-chip
program
memory
ROM/EPROM
Speed
MHz
No. of timers/
Counters
No. of
I/O lines
On-chip
Peripherals
8031
(MCS51-family)
128
ROM less
12
32
UART
8051
(MCS51-family)
128
4K ROM
12
32
UART
8052
(MCS51-family)
256
8K ROM
12
32
UART
(Contd)
256
8K EPROM
12
32
UART
87C58
(MCS51-family)
256
32K EPROM
12-24
32
UART
87C51GB
(MCS51-family)
256
8K EPROM
12-16
48
UART, 8
channel ADC
DMA
89C61x2
(MCS51-family)
1024
64K Flash
20-33
32
UART
AT89S8252
Atmel
256
8K Flash
2K EPROM
24
32
UART
SPI
16C74
(Microchip)
192
4K ROM
20
32
USART
8 bit ADC
SPI
16F874/877
(Microchip)
256
8K
20
32
USART
10 bit ADC
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
1.4
A microprocessor that fetches instruction and data using a single bus is called Von Neumann or Princeton
architecture. In Von Neumann architecture, data memory (RAM) and Program memory (ROM) are
connected by using single address and data bus as shown in Fig. 1.6.
In Harvard architecture, program memory and data memory are connected using separate address
and data bus to achieve fast execution speed for a given clock rate as shown in Fig. 1.7. For example,
10
8051 microcontroller by Intel and PIC microcontroller by microchip have Harvard architecture. Motorola
68HC11 microcontroller has Von Neumann architecture.
1.5
The microcontrollers with small instruction set are called Reduced Instruction Set Computer (RISC)
machines and those with complex instruction set are called Complex Instruction Set Computer (CISC)
machines. Intel 8051 microcontroller is an example of CISC machine and Microchip PIC16F87X is an
example of RISC machine. Comparison of features of RISC and CISC is shown in Table 1.2.
TABLE 1.2
CISC
6. Few instructions
1.
2.
3.
4.
1.6
COMPUTER SOFTWARE
A set of instructions written in a specic sequence for the computer to solve a specic task is called a
program, and software is a collection of programs. The program stored in the computer memory in the form
of binary numbers is called machine instructions. The machine language program is called object code.
For example, in 8051 microcontroller, the instruction CLR A is represented by binary code 11100100
(E4 in hexadecimal). Because it is difcult to write programs in sets of 0s and 1s, assembly language was
then developed to simplify the programming job. Machine language and assembly language are low level
languages and both are microprocessor specic. Assembly language programs are written using assembly
instructions. An assembly instruction is the mnemonic representation of machine instructions.
For example, in the instruction CLR A, CLR stands for clear and A represents the accumulator. This
symbol suggests the operation of storing 00H in the accumulator. The assembly language program that a
programmer enters is called the source program or source code. A software program called an assembler is
then developed to translate the program (source code) written in assembly language into machine language
(object code), which is compatible with the microprocessor being used in the system as shown in Fig. 1.8.
Mnemonics are specic to microprocessors and each microprocessor has its own assembler.
Thus, a compiler or an interpreter translates high level language program into machine language.
Each microprocessor needs its own compiler or an interpreter for each high level language. The primary
12
difference between a compiler and an interpreter lies in the process of generating machine code. The
compiler reads the entire program, translates it into object code and then it is executed by the processor. On
the other hand, the interpreter takes one statement of a high level language program as input and translates it
into object code and then executes. One of the major drawbacks of high level languages is that the machine
code compiled from high level language program cannot run as fast as machine codes of assembly language
program. For this reason, real time application programs are written in assembly language.
1.
2.
3.
4.
5.
1.7
In our daily lives, we are surrounded by number of embedded systems, such as TVs, DVD players, mobile
phones, washing machines, digital cameras and automobiles. In this section, we will study denition of
embedded systems, architecture of embedded systems, and embedded operating systems.
1.7.2
Based on the processor and software, various types of embedded systems exist. Reliability, cost effectiveness, low power consumption, fast execution time, efcient use of memory, and processing power are the
characteristics of most of the embedded systems.
Reliability Reliability of hardware and software is most important in embedded systems. The embedded
system should reboot and rest by itself without human intervention during failure. The co-design of
hardware and software is given importance in case of embedded system to meet these requirements.
Cost effectiveness The embedded systems are developed to meet the requirements of specic
applications, in mass markets, and hence, keeping the product cost reasonable becomes essential. To meet
the requirements, the system is developed using general-purpose processor during prototype. Then, an
application specic integrated circuit is used to reduce the hardware and cost.
Low power consumption Many embedded systems are battery operated. Power consumption has to
be limited to increase the life of the battery. This can be achieved by reducing the number of hardware
components or by designing the processor to revert to sleep mode when no operation is to be performed.
Fast execution time In real time embedded systems, certain tasks must be performed within a specic
time. To meet the performance constraints of real time systems, special operating systems known as real
time operating systems run on these embedded systems. To fulll the performance requirement, the code
should be optimal. The software is generally developed using high-level languages, some computationally
intensive units are developed in assembly language.
Efficient use of memory Most of the embedded systems contain only ROM and RAM without any
secondary storage. Flash memory is used to store the program, including the operating system. Most of the
microcontrollers and digital signal processors are available with on-chip ash memory.
Processing power The number of instructions executed per second is the processing power of the
processor. Most of the processors execute one instruction in one clock cycle. Therefore, the processing
power is in terms of million instructions per second (MIPS).
Central processing unit The central processing unit (CPU), which is also called processor is the heart
of the embedded system. The CPU can be any of the following
Microprocessor
Microcontroller
Digital signal processor
Application specic processor
14
Microprocessor Microprocessor is a single VLSI chip that has a CPU. It is used when large embedded
software is to be executed. Microprocessors are powerful and result in faster processing of instructions.
Table 1.3 lists the important microprocessors used in the embedded systems.
Microcontrollers Microcontrollers are also single VLSI chip, which have a CPU, memory, parallel ports,
serial ports, analog to digital converters and timers. Microcontrollers are used when small-embedded
software is to be executed and stored in its internal memory. Table 1.3 lists the important microcontrollers
used in the embedded systems.
Digital signal processors Digital signal processors are used where signal processing is involved such as
ltering, signal conversion from time to frequency domain, etc., and in applications like biomedical and
speech signal processing. Table 1.3 lists the important digital signal processors used in the embedded systems.
Application specific processors In application specic processors, processors are designed for running
the application specic tasks. They are the best choice where faster solution is required, as compared to
microprocessor and microcontroller. Application specic processors are used in mobile phones, TV
decoders, etc.
TABLE 1.3
Microprocessors
Microcontrollers
68HCxxx
Motorola
68HC11xx
Motorola
5600xx
Motorola
80x86
Intel
TMS320Cxx
Texas
SPARC
SUN
PIC16F84, PIC16F874
Microchip
SHARC
Analog Devices
Power PC
IBM
ARM 7
ARM
ADSP 21xx
Analog Devices
Memory An embedded system contains two types of semiconductor memoryrandom access memory
(RAM) and read only memory (ROM). Random access memory stores user program and data. Firmware
(embedded software) is stored in read only memory. When power is switched on, the processor executes the
embedded software stored in read only memory.
Input Devices Some embedded systems have input devices like small keypad, analog to digital
converters, switches whereas others do not have any input device for user interaction.
Output Devices Embedded systems have output devices like seven segment displays light emitting
diodes (LED) and liquid crystal displays (LCD) to display important parameters.
Application Specific Circuitry Depending on the application, embedded system contains transducers,
sensors, ampliers, and current to voltage conversion circuits. Function of these circuits is to convert
incoming signal to match the range of Analog-to-Digital (A/D) converter.
Communication Interfaces An embedded system can interact with other embedded systems using
serial communication bus like RS232, RS422 and IEEE bus.
Full-custom design Full-custom IC design is also referred to as Very Large Scale Integration (VLSI)
design. Full-custom Design is the name given to the technique where the function and layout of every
transistor is optimised. A microprocessor is an example of full custom IC. In this design, care has been
taken to squeeze every last square of micron of chip space. Full-custom ICs are the most expensive to
manufacture and to design.
Semi-custom design In case of semi-custom ICs, all of the logic cells are pre designed and some of
the mask layers are custom designed. The masks for the transistor and gate levels are already built. The
remaining design is to connect these gates to achieve a particular implementation. They provide good
performance with much less cost than full-custom ICs.
Programmable logic devices In Programmable Logic Devices (PLDs), all of the logic cells are predesigned and none of the mask layers are customised. There are two types in this category, namely
Programmable Logic Devices (PLD) and Field Programmable Gate Array (FPGA). In case of PLDs, all
layers already exist. One can purchase the IC and program it for intended design. The programming consists
of creating or destroying connections between connected gates, either by blowing a fuse, or setting a bit in
a programmable switch. A new inclusion to this family is Field Programmable Gate Arrays (FPGAs) that
offer more general connectivity among blocks of logic, rather than just arrays of logic as with PLDs. These
ICs are bigger in size, have higher unit cost and are slower compared to full-custom or semi-custom but
provide reasonable performance with reduced design time.
Co-design In an embedded system design, the task is implemented using hardware and software. The
design engineer has to decide which module needs to be implemented in hardware and which module is
to be realised by software. Hardware implementation imposes the constraints of size and cost. Software
implementation imposes the constraints of memory size and performance. To design an efcient embedded
system, co-design is a challenge.
16
Choice of operating system In the design of an embedded system, the designer has the option to develop
the software in assembly and C without using an operating system. This will result in efcient code, saving
processing power and memory. The other option is to use a readily available operating system, so that the
designer can focus on application software development. This saves development time and cost.
Optimizing of code In the design of embedded system, memory and execution time are the main
constraints. It is a challenge for the designer to optimise the code to meet the constraints.
Non real time embedded operating systems These operating systems are suitable for soft real time
embedded systems to perform tasks like memory management, I/O management, etc. They are not suitable
for hard real time applications. Examples are embedded windows XP, and embedded Linux.
Real time operating systems These operating systems are suitable for hard real time operating systems.
They are used to provide the necessary system calls for real time deadlines. Examples are OS/9, RT Linux,
and Vx works.
Mobile/handheld operating systems Operating systems that are used to work in mobile environments
are known as mobile operating systems. Examples are Embedded Windows NT, window CE, palm OS, and
syman OS.
In embedded systems, the operating system and the application software are integrated and stored in the
memory of the embedded system.