Microcontrollers: Veena Hegde, BMSCE, Bangalore
Microcontrollers: Veena Hegde, BMSCE, Bangalore
Microcontrollers: Veena Hegde, BMSCE, Bangalore
Text Books:
2. Muhammad Ali Mazidi and Janice Gillespie Mazidi and Rollin D.McKinlay; “The 8051
Microcontroller and Embedded Systems – using assembly and C ”- PHI, 2006 / Pearson, 2006
Sub: MICROCONTROLLERS
Semester: IV, BE
PART – A
The 8051 Architecture: Introduction, 8051 Microcontroller Hardware, Input/Output Pins, Ports
and Circuits, External Memory, Counters and Timers, Serial Data Input/Output, Interrupts.
7
Hours
The computer hardware consists of four main components. The central processing unit which
acts as computer’s brain. Input unit through which program and data can be entered to computer,
output unit on which the results of the computations can be displayed. Memory in which data
and program are stored.
Microprocessor or ‘Computer on Chip’ first became a commercial reality in 1971 with the
introduction of the 4 bit 4004 by Intel. A byproduct of Microprocessor development was
Microcontroller. The same fabrication technology and programming concept that make the
general purpose microprocessor also yielded the Microcontroller.
Microprocessors
A microprocessor is a general purpose digital computer central processing unit (CPU). Although
known as a ‘Computer on Chip’ the Microprocessor in no sense a complete digital computer.
Block diagram of a Microprocessor CPU which contains ALU; Program counter (PC), a stack
pointer (SP) ,some working registers , a clock timing circuit and interrupt circuit s is shown in
the following figure
Arithmetic and
Logic Unit
Accumulator
Working Register
To make a computer microcomputer one must add memory usually RAM and ROM,
memory decoders , an oscillator and a number of Input ,Output devices such as serial and parallel
ports. In addition special purpose devices such as interrupt handler and counters may be added to
relieve the CPU from time consuming counting or timing cores. When the Microcomputer is
equipped with mass storage devices , I/O peripherals such as a key board and a display CRT it
yields a small computer that can be applied to a range of general purpose applications.
The hardware design of a microprocessor is arranged such that a very small or very large
system can be configured around the CPU as the application demands as shown in Fig1. The
prime use of the Microprocessor is to read data , perform extensive calculations on that data, and
store those calculations in a mass storage device or display the results for human use. The
programs used by microprocessor are stored in the mass storage device and loaded into RAM as
user directs. A few microprocessor program are stored in ROM . The ROM based programs are
primarily small fixed programs that operate peripherals and other fixed devices that are
connected to the system.
A microcontroller can be compared to a Swiss knife with multiple functions incorporated in the
same Integrated Circuits. Block diagram of a typical Microcontroller which is a true computer on
a chip is shown below. The design incorporates all the features found in microprocessor CPU :
ALU,PC, SP and registers. It also has other features needed to make a complete computer: ROM,
RAM, Parallel I/O, serial I/O, Counters and clock circuits. Like the microprocessor , a
microcontroller is a general purpose device, but one that is meant to read data, perform limited
calculations on that data and control its environment based on those calculations. The prime use
of microcontroller is to control the operation of a machine using a fixed program that is stored in
ROM and that does not change over the lifetime of the system.
Memory in those days was expensive. Bigger programs required more storage which
included more money . There was a need to reduce the number of instructions per program .
This was achieved by having multiple operations within single instruction. Multiple
operations lead to many different kinds of instructions .Access to memory in turn makes the
instruction length variable and fetch-decode execute time unpredictable – making it more
complex. Thus hardware was made to understand the complexity of instruction set. The
computer having such instruction set was named as Complex Instruction Set Computer
(CISC). Intel 8051 is an example for CISC architecture.
In applications which require more of input , output related operations having few simple
instructions that are of the same length allows memory access only with explicit load and
store instructions. Hence each instruction performs less work but instruction execution time
among different instructions is consistent. This would lead to instruction execution by
hardware including multiple number of registers inside CPU. The computer using such
instructions is called Reduced Instruction Set Computer (RISC). PIC microcontroller
manufactured by Microchip Company is an example for RISC architecture.
In a microprocessor, input /output (I/O) devices are externally interfaced and are mapped
either to memory address (memory mapped I/O) or a separate I/O address space (I/O mapped
I/O). There are two possible architectures one is Princeton (Von Neumann) and another is
Harvard .I/O Registers space in Princeton architecture have only one memory interface for
program memory (ROM) and data memory (RAM). One option is to map the I/O Register as
a part of data memory or variable RAM area ( memory mapped I/O). Alternatively a separate
I/O register space can be assigned (I/O Mapped I/O) . Both the arrangements are shown in
Fig.4.
As shown in Fig 4. Program memory and Data memory are together in both the
arrangements. The Princeton or Vonneumann architecture one bus is used to carry the address
and data with an appropriate multiplexing technique ,which in turn reduces the cost. But
Harvard architecture which 8051 employs has separate Data memory and separate Code or
Program memory . The Fig. 5 and Fig .6 show the need for separate address and data bus for
each Program and Data memory in Harvard architecture. Since there are separate bus for
access the operation of fetching the code and data can happen simultaneously which
increases the speed of operation of execution inside CPU.
In Fig. 5 , the first option is difficult to implement as there is no means to write to program
ROM area. It is also complicated to have a separate I/O space as shown in (3). Hence the
second option where I/O registers are placed in the register space is widely used in Harvard
architecture. Data
Data
Memory
C Addres
P s
U Data
Program
Memory
Addres
s
numbers an intermediate level of language for programming, between higher and machine
level was developed and is known as assembly level language . Assembly language programs
are written using assembly instructions known as mnemonics.
For example in CLR A, instruction CLR means clear and A means accumulator. The program
mnemonics are converted to machine codes in the form of binary by a software called
Assembler.
P3.0 RxD
P3.1 TxD
P3.2
P3.3
P3.4 T0
P3.6
P3.7