Microprocessor & Microcontroller Syllabus
Microprocessor & Microcontroller Syllabus
Module-3
Microprocessor & Microcontroller
Syllabus: Microprocessor & Microcontrollers: Introduction, Microprocessor systems, Basic
elements of control systems, Microcontrollers, Difference between Microprocessor and
Microcontrollers. Microprocessor Architecture: Microprocessor architecture and
terminology-CPU, memory and address, I/O and Peripheral devices, ALU, Instruction and
Program, Assembler, Data Registers, Program Counter, Flags, Fetch cycle, write cycle,
state, bus interrupts. Intel’s 8085A Microprocessor.
Note: some of the topics covered in notes are extra. There may be possibility those question
appear in exam.
1
Jawaharlal Nehru National college of Engineering, Shimoga MKS
A typical microprocessor consists of arithmetic and logic unit (ALU) in association with
control unit to process the instruction execution. Almost all the microprocessors are based on
the principle of store-program concept. In store-program concept, programs or instructions
are sequentially stored in the memory locations that are to be executed. To do any task using
a microprocessor, it is to be programmed by the user. So, the programmer must have idea
about its internal resources, features and supported instructions. Each microprocessor has a
set of instructions, a list which is provided by the microprocessor manufacturer. The
instruction set of a microprocessor is provided in two forms: binary machine code and
mnemonics.
Microprocessor communicates and operates in binary numbers 0 and 1. The set of
instructions in the form of binary patterns is called a machine language and it is difficult for
us to understand. Therefore, the binary patterns are given abbreviated names, called
mnemonics, which forms the assembly language. The conversion of assembly-level language
into binary machine-level language is done by using an application called assembler.
2
Jawaharlal Nehru National college of Engineering, Shimoga MKS
3
Jawaharlal Nehru National college of Engineering, Shimoga MKS
Buses
A bus is a high-speed internal connection. Buses are used to send control signals and data
between the processor and other components.
Three types of bus are used.
Address bus - carries memory addresses from the processor to other components such as
primary storage and input/output devices. The address bus is unidirectional.
Data bus - carries the data between the processor and other components. The data bus is
bidirectional.
Control bus - carries control signals from the processor to other components. The control
bus also carries the clock's pulses. The control bus is unidirectional.
Classification of Microprocessors:
Based on their specification, application and architecture microprocessors are classified.
Based on size of data bus:
4-bit microprocessor
8-bit microprocessor
16-bit microprocessor
32-bit microprocessor
Based on application:
1. General-purpose microprocessor- used in general computer system and can be used
by programmer for any application. Examples, 8085 to Intel Pentium.
2. Microcontroller- microprocessor with built-in memory and ports and can be
programmed for any generic control application. Example, 8051.
3. Special-purpose processors- designed to handle special functions required for an
application. Examples, digital signal processors and application-specific integrated
circuit (ASIC) chips.
Based on architecture:
1. Reduced Instruction Set Computer (RISC) processors
2. Complex Instruction Set Computer (CISC) processors
4
Jawaharlal Nehru National college of Engineering, Shimoga MKS
5
Jawaharlal Nehru National college of Engineering, Shimoga MKS
The 8085 has six general-purpose registers to store 8-bit data; these are identified as B, C,
D, E, H and L. they can be combined as register pairs - BC, DE and HL to perform some16-
bit operations. The programmer can use these registers to store or copy data into the
register by using data copy instructions.
6
Jawaharlal Nehru National college of Engineering, Shimoga MKS
1) The carry flag (CF):-This flag is set whenever there has been a carry out of, or a borrow
into, the higher order bit of the result. The flag is used by the instructions that add and
subtract multibyte numbers.
1-carry out from MSB bit on addition or borrow into MSB bit on subtraction.
0-no carry out or borrow into MSB bit
2) The parity flag (PF):-This flag is set whenever the result has even parity, an even number
of 1 bits. If parity is odd, PF is cleared.
1-low byte has even number of 1 bits
0-low byte has odd parity
3) The auxiliary carry flag (AF):-This flag is set whenever there has been a carry out of the
lower nibble into the higher nibble or a borrow from higher nibble into the lower nibble of an
8 bit quantity, else AF is reset. This flag is used by decimal arithmetic instructions.
1-carry out from bit 3 on addition or borrow into bit 3 on subtraction
0-otherwise
4) The zero flag(ZF):-
This flag is set, when the result of operation is zero, else it is reset.
1-zero result
0-non-zero result
5) The sign flag(SF):-This flag is set, when MSB (Most Significant Bit) of the result is 1.
Since negative binary numbers are represented in the 8085 CPU in standard two’s
complement notation, SF indicates sign of the result.
1-MSB is 1 (negative)
0-MSB is 0 (positive)
Program Counter (PC)
This 16-bit register deals with sequencing the execution of instructions. This register is
amemory pointer. The microprocessor uses this register to sequence the execution of the
instructions. The function of the program counter is to point to the memory address from
which the next byte is to be fetched. When a byte is being fetched, the program counter is
automatically incremented by one to point to the next memory location.
Stack Pointer (SP)
The stack pointer is also a 16-bit register, used as a memory pointer. It points to a memory
location in R/W memory, called stack. The beginning of the stack is defined by loading 16-
bit address in the stack pointer.
7
Jawaharlal Nehru National college of Engineering, Shimoga MKS
Instruction Register/Decoder
It is an 8-bit register that temporarily stores the current instruction of a program. Latest
instruction sent here from memory prior to execution. Decoder then takes instruction and
decodes or interprets the instruction. Decoded instruction then passed to next stage.
Control Unit
Generates signals on data bus, address bus and control bus within microprocessor to carry out
the instruction, which has been decoded. Typical buses and their timing are described as
follows:
Data Bus: Data bus carries data in binary form between microprocessor and other
external units such as memory. It is used to transmit data i.e. information, results of
arithmetic etc between memory and the microprocessor. Data bus is bidirectional in
nature. The data bus width of 8085 microprocessor is 8-bit i.e. 28 combination of
binary digits and are typically identified as D0 – D7. Thus size of the data bus
determines what arithmetic can be done. If only 8-bit wide then largest number is
11111111 (255 in decimal). Therefore, larger numbers have to be broken down into
chunks of 255. This slows microprocessor.
Address Bus: The address bus carries addresses and is one way bus from
microprocessor to the memory or other devices. 8085 microprocessor contain 16-bit
address bus and are generally identified as A0 - A15. The higher order address lines
(A8 – A15) are unidirectional and the lower order lines (A0 – A7) are multiplexed
(time-shared) with the eight data bits (D0 – D7) and hence, they are bidirectional.
Control Bus: Control bus are various lines which have specific functions for
coordinating and controlling microprocessor operations. The control bus carries
control signals partly unidirectional and partly bidirectional. The following control
and status signals are used by 8085 processor:
1. ALE (output): Address Latch Enable is a pulse that is provided when an address
appears on the AD0 – AD7 lines, after which it becomes 0.
2. RD (active low output): The Read signal indicates that data are being read from
the selected I/O or memory device and that they are available on the data bus.
3. WR (active low output): The Write signal indicates that data on the data bus are to
be written into a selected memory or I/O location.
8
Jawaharlal Nehru National college of Engineering, Shimoga MKS
0 0 Halt
0 1 Write
1 1 Read
1 1 Fetch
9
Jawaharlal Nehru National college of Engineering, Shimoga MKS
Properties:
1. It is a 8-bit microprocessor
2. Manufactured with N-MOS technology
3. 40 pin IC package
4. It has 16-bit address bus and thus has 216 = 64 KB addressing capability.
5. Operate with 3 MHz single-phase clock
6. +5 V single power supply
The logic pin layout and signal groups of the 8085nmicroprocessor are shown in
Fig.6. All the signals are classified into six groups:
1. Address bus
2. Data bus
3. Control & status signals
4. Power supply and frequency signals
5. Externally initiated signals
6. Serial I/O signals
Address and Data Buses:
A8 – A15 (output, 3-state): Most significant eight bits of memory addresses and the
eight bits of the I/O addresses. These lines enter into tri-state high impedance state
during HOLD and HALT modes.
AD0 – AD7 (input/output, 3-state): Lower significant bits of memory addresses and
the eight bits of the I/O addresses during first clock cycle. Behaves as data bus during
third and fourth clock cycle. These lines enter into tri-state high impedance state
during HOLD and HALT modes.
Control & Status Signals:
1. ALE: Address latch enable
2. : Read control signal.
3. : Write control signal.
4. IO/ , S1 and S0 : Status signals.
Power Supply & Clock Frequency:
Vcc: +5 V power supply
Vss: Ground reference
X1, X2: A crystal having frequency of 6 MHz is connected at these two pins
CLK: Clock output
10
Jawaharlal Nehru National college of Engineering, Shimoga MKS
11
Jawaharlal Nehru National college of Engineering, Shimoga MKS
The following sequence of operations takes place when an interrupt signal is recognized:
1. Save the PC content and information about current state (flags, registers etc) in the
stack.
2. Load PC with the beginning address of an ISR and start to execute it.
3. Finish ISR when the return instruction is executed.
4. Return to the point in the interrupted program where execution was interrupted.
13
Jawaharlal Nehru National college of Engineering, Shimoga MKS
The following figure shows the contents of Stack Memory, PC, Incrementer/Decrementor
before and after ISR-Interrupt Service Routine. The main program is suspended by ISR. The
content of present memory location where interrupt occurred, contents of PC, SP are pushed
to stack memory. After the interrupt is acknowledged, the contents SP, PC and Memory
content and location of main programs is restored. The control resumes the execution of the
main programs.
14
Jawaharlal Nehru National college of Engineering, Shimoga MKS
Table-2
T1 clock cycle
The content of PC is placed in the address bus; AD0 - AD7 lines contains lower bit
address and A8 – A15 contains higher bit address.
IO/ signal is low indicating that a memory location is being accessed. S1 and S0 also
changed to the levels as indicated in Table 1.
ALE is high, indicates that multiplexed AD0 – AD7 act as lower order bus.
T2 clock cycle
Multiplexed address bus is now changed to data bus.
The signal is made low by the processor. This signal makes the memory device
load the data bus with the contents of the location addressed by the processor.
T3 clock cycle
The opcode available on the data bus is read by the processor and moved to
theinstruction register.
The signal is deactivated by making it logic 1.
15
Jawaharlal Nehru National college of Engineering, Shimoga MKS
T4 clock cycle
The processor decode the instruction in the instruction register and generate the
necessary control signals to execute the instruction. Based on the instruction further
operations such as fetching, writing into memory etc takes place.
16
Jawaharlal Nehru National college of Engineering, Shimoga MKS
17
Jawaharlal Nehru National college of Engineering, Shimoga MKS
18
Jawaharlal Nehru National college of Engineering, Shimoga MKS
Microcontrollers
A microcontroller is a small and low-cost microcomputer, which is designed to perform
the specific tasks of embedded systems like displaying microwave’s information,
receiving remote signals, etc.
The general microcontroller consists of the processor, the memory (RAM, ROM,
EPROM), Serial ports, peripherals (timers, counters), etc
19
Jawaharlal Nehru National college of Engineering, Shimoga MKS
computation. Control Unit (CU) is responsible for timing of the communication process
between the CPU and its peripherals.
Memory
To perform any specific task microcontroller required a group of instructions which is called
program. So to store these program microcontroller having a memory called program
memory or code memory. In microcontroller ROM (Read only memory) is used as a program
memory to store program or instructions. Program Memory generally made up of EEPROM
(Electrically Erasable Programmable Read – only Memory), which is a type of non – volatile
memory. In this type of memory, the data can be erased and reprogrammed using special
programming signals.
To store data, microcontroller having a sperate memory called data memory. Microcontroller
used RAM (Random Access Memory ) for temporarily storing of data and the auxiliary
results generated during the runtime. RAM is volatile memory since cutting off power to the
IC will result in loss of information or data.
In microcontroller 8051 there is code or program memory of 4 KB that is it has 4 KB ROM
and it also have data memory (RAM) of 128 bytes.
Bus
Group of wires is called BUS. which uses as a communication channel or it acts as means of
data transfer. In microcontroller buses consists of 8, 16 or more wires. Thus, these can carry 8
bits,16 bits simultaneously.
There are two type of buses used in microcontroller :
Address Bus: It is used for transferring the data from CPU (Central Processing Unit) to
Memory.
Data Bus: It is used for transferring the data from one peripherals to other peripherals.
Input and Output Ports
The ports allow the microcontroller to connect with external devices, machines or other
peripherals. Each port has specific number of pins. All ports are bidirectional. Each port has
a latch and driver (or buffer).
Timers/Counters
The microcontroller has two 16-bit Programmable timers / counters (Timer 0 – Timer 1).
Which can be used either as timer to generate a time delay or as counter to count events
happening outside the microcontroller.
20
Jawaharlal Nehru National college of Engineering, Shimoga MKS
Oscillator
The microcontroller is a digital device, therefore it requires clock pulses for its operation. To
synchronize all the part of microcontroller and perform operation microcontroller has an on-
chip oscillator which works as a clock source for Central Processing Unit of the
microcontroller.
Interrupts
Interrupts are the events that temporarily suspend the main program executed by the
microcontroller. Intimate the microcontroller by sending it an interrupt signal (inform
microcontroller that a device needs its service). When Microcontroller receiving an interrupt
signal, the microcontroller interrupts whatever it is doing and serves the device. After that
microcontroller resume the execution main program.
The program which associated with interrupt is called ISR (Interrupt Service Routine) or
Interrupt handler. ISR is a set of instructions when executed providing the service to
interrupted device. For every Interrupt , there is a fixed location in memory that hold the
address of its ISR. The group of memory location set aside to hold the address of ISR is
called Interrupt vector table.
Applications of Microcontroller
Now a day there are vast application of microcontroller in various fields. Microcontroller is
mainly used in daily life, industries , medical, automobile and defence applications etc.
21
Jawaharlal Nehru National college of Engineering, Shimoga MKS
Microprocessor Vs Microcontroller
Microprocessor Microcontroller
1 Microprocessor is the heart of Computer Micro Controller is the heart of an
system. embedded system.
2 It is only a processor, so memory and I/O Micro Controller has a processor along
components need to be connected externally with internal memory and I/O components.
3 Memory and I/O has to be connected Memory and I/O are already present, and
externally, so the circuit becomes large. the internal circuit is small.
4 You can’t use it in compact systems You can use it in compact systems.
5 Cost of the entire system is high Cost of the entire system is low
6 Due to external components, the total power As external components are low, total
consumption is high. Therefore, it is not power consumption is less. So it can be
ideal for the devices running on stored power used with devices running on stored power
like batteries. like batteries.
7 Most of the microprocessors do not have Most of the microcontrollers offer power-
power saving features. saving mode.
8 It is used mainly in a washing machine,
It is mainly used in personal computers.
MP3 players, and embedded systems.
9 Microprocessor has a smaller number of
Microcontroller has more register. Hence
registers, so more operations are memory-
the programs are easier to write.
based.
10 Microprocessors are based on Von Neumann Micro controllers arc based on Harvard
model architecture
11
It is a by-product of the development of
It is a central processing unit on a single
microprocessors with a CPU along with
silicon-based integrated chip.
other peripherals.
22
Jawaharlal Nehru National college of Engineering, Shimoga MKS
23