Muthayammal Engineering College
Muthayammal Engineering College
L1
LECTURE HANDOUTS
EEE
Course N II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
16-bit Microprocessor
It does not have any 128-bit Microprocessor in work at present one among the reasons for this
is that we are a long way from exhausting the 64 bit address space itself, we use it a constant
rate of roughly 2 bits every 3 years. At present we have only used 48 bits of 64 bits so why
require 128 bit address space. Also 128 bit Microprocessor would be much slower than the 64
bit Microprocessor.
Types of Processor:
Example:
Intel 386
Intel 486
Pentium
Pentium Pro
Pentium II
Pentium III
Motorola 68000
Motorola 68020
Motorola 68040 etc.
www.youtube.com/watch?v=liRPtvj7bFU&noredirect=1
B H Khan, Non – Conventional Energy Resources ,Tata McGraw Hill Education Private
Limited , New Delhi 2010-Page no (15-19)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L2
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APLICATIONS
The ALU performs the actual numerical and logical operations such as
Addition (ADD), Subtraction (SUB), AND, OR etc.
It uses data from memory and from Accumulator to perform operations.
The results of the arithmetic and logical operations are stored in the
accumulator.
Registers
The 8085 includes six registers, one accumulator and one flag register, as shown in
Figure. In addition, it has two 16-bit registers: stack pointer and program counter.
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.
Accumulator
The accumulator is an 8-bit register that is a part of ALU.
This register is used to store 8-bit data and to perform arithmetic and logical
operations.
The result of an operation is stored in the accumulator.
The accumulator is also identified as register A.
Flag register
The ALU includes five flip-flops, which are set or reset after an operation according
to data condition of the result in the accumulator and other registers.
They are called Zero (Z), Carry (CY), Sign (S), Parity (P) and Auxiliary Carry (AC)
flags.
Their bit positions in the flag register are shown in Figure. The microprocessor uses
these flags to test data conditions.
Flag register
Program Counter (PC)
This 16-bit register deals with sequencing the execution of instructions. This
register is a memory 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.
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.
Control Unit
Generates signals on data bus, address bus and control bus within microprocessor
to carry out the instruction, which has been decoded.
https://www.youtube.com/watch?v=_qtCAuLIaew
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L3
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
ALE (Output):
Address Latch Enable: It occurs during the first clock cycle of a machine state
and enables the address to get latched into the on chip latch of peripherals.
The falling edge of ALE is set to guarantee setup and hold times for the address
information. ALE can also be used to strobe the status information. ALE is never
3stated.
SO, S1 (Output):
Data Bus Status. Encoded
status of the bus cycle:
S1 S0
0 0 HALT
0 1 WRITE
1 0 READ
1 1 FETCH S1 can be used as an advanced R/W status.
RD (Output 3state):
READ: indicates the selected memory or I/0 device is to be read and that the Data Bus
is available for the data transfer.
WR (Output 3state):
WRITE: indicates the data on the Data Bus is to be written into the selected memory or
I/0location.
Data is set up at the trailing edge of WR. 3stated during Hold and Halt modes.
READY (Input):
If Ready is high during a read or write cycle, it indicates that the memory or
peripheral is ready to send or receive data.
If Ready is low, the CPU will wait for Ready to go high before completing the read or
write cycle.
HOLD (Input):
HOLD: indicates that another Master is requesting the use of the Address and Data
Buses.
The CPU, upon receiving the Hold request will relinquish the use of buses as soon as
the completion of the current machine cycle.
Internal processing can continue. The processor can regain the buses only after the
Hold is removed. When the Hold is acknowledged, the Address, Data, RD, WR, and
IO/M lines are 3stated.
HLDA (Output):
HOLD ACKNOWLEDGE: indicates that the CPU has received the Hold request
and that it will relinquish the buses in the next clock cycle.
HLDA goes low after the Hold request is removed. The CPU takes the buses one
half clock cycle after HLDA goes low.
INTR (Input):
INTERRUPT REQUEST is used as a general purpose interrupt. It is sampled only
during the next to the last clock cycle of the instruction. If it is active, the Program
Counter (PC) will be inhibited from incrementing and an INTA will be issued.
During this cycle a RESTART or CALL instruction can be inserted to jump to the
interrupt service routine. The INTR is enabled and disabled by software. It is
disabled by Reset and immediately after an interrupt is accepted.
INTA (Output):
INTERRUPT ACKNOWLEDGE: is used instead of (and has the same timing as) RD
during the Instruction cycle after an INTR is accepted.
It can be used to activate the 8259 Interrupt chip or some other interrupt port.
RESTART INTERRUPTS:
These three inputs have the same timing as INTR except they cause an
internal RESTART to be automatically inserted.
RST 7.5 Highest Priority
RST 6.5
RST 5.5 Lowest Priority
RESET IN (Input):
Reset sets the Program Counter to zero and resets the Interrupt Enable and
HLDA flipflops.
None of the other flags or registers (except the instruction register) are affected The
CPU is held in the reset condition as long as Reset is applied.
X1, X2 (Input):
Crystal or R/C network connections to set the internal clock generator X1 can also
be an external clock input instead of a crystal. The input frequency is divided by 2 to
give the internal operating frequency.
CLK (Output):
Clock Output for use as a system clock when a crystal or R/ C network is used as an
input to the CPU. The period of CLK is twice the X1, X2 input period.
IO/M (Output):
IO/M indicates whether the Read/Write is to memory or l/O Tristated during Hold and
Halt modes.
SID (Input):
Serial input data line The data on this line is loaded into accumulator bit 7 whenever a
RIM instruction is executed.
SOD (output):
Serial output data line. The output SOD is set or reset as specified by the SIM instruction.
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L4
LECTURE HANDOUTS
EEE II/IV
Introduction :
Rd,
Copy from the source (Sc) to
MOV Sc M, Example − MOV K, L
the destination(Dt)
Sc Dt,
M
Rd, data
MVI Move immediate 8-bit Example − MVI K, 55L
M, data
LDAX B/D Reg. pair Load the accumulator indirect Example − LDAX K
Example − LHLD
LHLD 16-bit address Load H and L registers direct
3225K
POP Reg. pair Pop off stack to the register pair the Example − POPK
CONTROL INSTRUCTIONS:
Read
This instruction is used to read the status of
RIM None interrupt
interrupts 7.5, 6.5, 5.5 and read serial data input bit.
mask
Compare the
R register or The contents of the operand (register or memory)
CMP
M memory with the are M compared with the contents of the
accumulator accumulator.
Compare
8-bit The second byte data is compared with the contents
CPI immediate with
data of the accumulator.
the accumulator
Logical AND
R The contents of the accumulator are logically AND
register or
ANA with M the contents of the register or memory, and
M memory with the
the result is placed in the accumulator.
accumulator
Exclusive OR
R The contents of the accumulator are Exclusive OR
register or
XRA with M the contents of the register or memory, and
M memory with the
the result is placed in the accumulator.
accumulator
Logical OR
R The contents of the accumulator are logically OR
register or
ORA with M the contents of the register or memory, and
M memory with the
result is placed in the accumulator.
accumulator
ARITHMETIC INSTRUCTUIONS:
Opcode Operand Meaning Example
https://www.youtube.com/watch?v=G3iUO96XhC4
Important Books/Journals For Further Learning Including The Page Nos.:
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L5
LECTURE HANDOUTS
EEE II/IV
o Direct Addressing
In this addressing mode, the address of the operand (data) is given in the instruction itself.
Example
STA 2400H: It stores the content of the accumulator in the memory location 2400H.
It is given in the instruction itself. The 2nd and 3rd bytes of the instruction specify the
address of the memory location.
o Register Addressing
In register addressing mode, the operand is in one of the general purpose registers. The
Opcode specifies the address of the register(s) in addition to the operation to be performed.
Example:
In the above example, MOV A, B is 78H. Besides the operation to be performed the
opcode also specifies source and destination registers.
The opcode 78H can be written in binary form as 01111000. The first two bits, i.e. 0 1 are
for MOV operation, the next three bits 1 1 1 are the binary code for register A, and the
last three bits 000 are the binary code for register B.
Example
o Immediate Addressing
In this addressing mode, the operand is specified within the instruction itself.
Example
LXI H, 2500 is an example of immediate addressing. 2500 is 16-bit data which is given
in the instruction itself. It is to be loaded into H-L pair.
o Implicit Addressing
There are certain instructions which operate on the content of the accumulator. Such
instructions do not require the address of the operand.
Example
https://www.youtube.com/watch?v=nJfTvmYjR90
Important Books/Journals for further learning including the page nos.:
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L6
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
https://www.youtube.com/watch?v=nJfTvmYjR90
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
LECTURE HANDOUTS L7
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Instruction Cycle
The time required to execute an instruction is called instruction cycle.
Machine Cycle
The time required to access the memory or input/output devices is called machine
cycle.
T-State
The machine cycle and instruction cycle takes multiple clock periods.
The 8085 microprocessor has 5 (seven) basic machine cycles. They are
1. Opcode fetch cycle (4T)
2. Memory read cycle (3 T)
3. Memory write cycle (3 T)
4. I/O read cycle (3 T)
5. I/O write cycle (3 T)
1.Opcode fetch machine cycle of 8085 :
The I/O Read cycle is executed by the processor to read a data byte from
I/O port or from the peripheral, which is I/O, mapped in the system.
The processor takes 3T states to execute this machine cycle.
The IN instruction uses this machine cycle during the execution
o Fetching the Opcode 34H from the memory 4105H. (OF cycle)
o Let the memory address (M) be 4250H. (MR cycle -To read Memory
address and data) Let the content of that memory is 12H.
o Increment the memory content from 12H to 13H. (MW machine cycle)
https://www.youtube.com/watch?v=EaRqC3dLoWY
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
LECTURE HANDOUTS L8
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APLLICATIONS
Timing Diagram
Mapped Memory
Simplicity is the advantage of mapping memory among the devices in a system:
o There is no need to partition data. All devices see the complete memory image.
There is no need to use streams to overlap data transfers with kernel execution. All
data transfers originate from the kernel and are asynchronous.
Application performance is the cost associated with this simplicity. Using mapped
memory does mean that the programmer gives up control over the data movement between
the host and devices. From the forums and experience, it is not unusual for kernel
performance to drop when using mapped memory because there are no guarantees when or
how often data will need to be transferred across the PCIe bus. Other considerations to using
mapped memory include:
If the contents of the mapped memory are modified, the application must
synchronize memory accesses using streams or events to avoid any potential
read-after-write, write-after-read, or write-after write hazards.
The host memory needs to be page aligned. The simplest and most portable
way to enforce this is to use when allocating mapped host memory.
The simplicity of using mapped memory is illustrated by which fills a mapped memory
vector using one or more GPUs in the system. The highlighted command creates a mapped
region of memory when passed the flag. This region is freed at the end of the program with
Thrust was used to make this code concise and easy to read.
The device_pointer_cast method was used to correctly cast the mapped host memory for
the thrust sequence method.
The highlighted call to ensures that the mapped data is synchronized between the host
and devices prior to checking the results on the host. All data transfers occur transparently
and asynchronously. Finally, the contents of the mapped region of memory are checked for
correctness on the host and the mapped region is freed.
Memory Maps
An example of the memory map for a simple system. It is not a complete system, but
instead it is just intended to show a few typical cases of memory mappings. The processor
has a memory map that shows how RAM and a few devices are mapped, as well as a PCIe
memory space in which PCIe devices are mapped.
The basic building block for creating memory maps are objects of the memory-space
class. When a memory transaction is initiated from an origin, typically a processor model, the
For a processor model, the first memory space typically represents the physical address
space of the processor. If nothing is mapped at address a, an access error is signaled to the
origin.
However, if the access falls within the range of a second memory space that is mapped
in the first memory space at offset b, the transaction is passed on to the second memory space
with the local address c=a−b. Memory spaces are traversed in this fashion until an unmapped
address is reached or the transaction terminates in a device model. This process is shown
in Figure.
https://www.youtube.com/watch?v=jkT9Bgz8PAg
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L9
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
The memory is made up of semiconductor material used to store the programs and
data.
Data in Microprocessor can move from one location to another.
Classification of Memories
Process memory
Secondary memory
Typical EPROM and Static RAM
Having two power supply pins (one for connecting required supply voltage
and the other for connecting ground).
The control signals needed for static RAM are chip select (chip enable), read
control(output enable) and write control (write enable).
The control signals needed for read operation in EPROM are chip select (chip
enable) and read control (output enable).
Block Diagram of 2-4 Decoder
Consider a system in which the full memory space 64kb is utilized for EPROM memory.
Interface the EPROM with 8085 processor.
o In this system the entire 16 address lines of the processor are connected to
address input pins of memory IC in order to address the internal locations of
memory.
o The chip select (CS) pin of EPROM is permanently tied to logic low (i.e., tied to
ground).
o Since the processor is connected to EPROM, the active low RD pin is connected
to active low output enable pin of EPROM.
Video Content / Details of website for further learning (if any):
https://www.youtube.com/watch?v=jkT9Bgz8PAg
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L10
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Introduction :
Microcontroller performs some basic operations like addition, subtraction,
multiplication, division and some logical operations using its Arithmetic and Logical
Unit (ALU).
New Microcontroller also perform operations on floating point numbers also.
Data in Microcontroller can move from one location to another.
It has a Program Counter (PC) register that stores the address of next instruction
based on the value of PC, Microcontroller jumps from one location to another and
takes decision.
From the above image, you can understand that the three important (or major) components
of a Microcontroller are:
The CPU (Central Processing Unit)
The Memory and
The I/O Ports
This doesn’t mean that other components are of less importance. But these can be considered
as supporting devices. We will now see each of the Basic Components of a Microcontroller
mentioned in the above structure.
CPU
Memory
Any Computational System requires two types of Memory: Program Memory and Data
Memory. Program Memory, as the name suggests, contains the program i.e. the instructions
to be executed by the CPU. Data Memory on the other hand, is required to store temporary
data while executing the instructions.
Usually, Program Memory is a Read Only Memory or ROM and the Data Memory is a
Random Access Memory or RAM. Data Memory is sometimes called as Read Write Memory
(R/W M).
I/O Ports
The interface for the Microcontroller to the external world is provided by the I/O Ports or
Input/Output Ports. Inputs device like Switches, Keypads, etc. provide information from the
user to the CPU in the form of Binary Data.
The CPU, upon receiving the data from the input devices, executes appropriate instructions
and gives response through Output Devices like LEDs, Displays, Printers, etc.
Bus
Another important component of a Microcontroller, but rarely discussed is the System Bus.
A System bus is a group of connecting wire that connect the CPU with other peripherals like
Memory, I/O Ports and other supporting components.
Timers/Counters
One of the important components of a Microcontroller are the Timers and Counters. They
provide the operations of Time Delays and counting external events. Additionally, Timers
and Counters can provide Function Generation, Pulse Width Modulation, Clock Control, etc.
Serial Port
Analog to Digital Converter or ADC is a circuit that converts Analog signals to Digital
Signals. The ADC Circuit forms the interface between the external Analog Input devices and
the CPU of the Microcontroller. Almost all sensors are analog devices and the analog data
from these sensors must be converted in to digital data for the CPU to understand.
DIgital to Analog Converter or DAC is a circuit, that works in contrast to an ADC i.e. it
converts Digital Signals to Analog Signals. DAC forms the bridge between the CPU of the
Microcontroller and the external analog devices.
Advantages of Microcontrollers
Disadvantages of Microcontrollers
Applications of Microcontrollers
There are huge numbers of applications of Microcontrollers. In fact, the entire embedded
systems industry is dependent on Microcontrollers. The following are few applications of
Microcontrollers.
www.youtube.com/watch?v=liRPtvj7bFU&noredirect=1
Important Books/Journals for further learning including the page nos.:
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 Page No: 24-28
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L11
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
8051 MICROCONTROLLERARCHITECTURE
CPU (Central Processing Unit): CPU act as a mind of any processing machine. It
synchronizes and manages all processes that are carried out in microcontroller. User has no
power to control the functioning of CPU. It interprets the program stored in ROM and carries
out from storage and then performs it projected duty. CPU manage the different types of
registers available in 8051 microcontroller.
Interrupts: Interrupts is a sub-routine call that given by the microcontroller when some other
program with high priority is request for acquiring the system buses the n interrupts occur in
current running program.
Interrupts provide a method to postpone or delay the current process, performs a sub-routine
task and then restart the standard program again.
Types of interrupt in 8051 Microcontroller:
Memory: For operation Micro-controller required a program. This program guides the
microcontroller to perform the specific tasks. This program installed in microcontroller
required some on chip memory for the storage of the program.
Microcontroller also required memory for storage of data and operands for the short
duration. In microcontroller 8051 there is code or program memory of 4 KB that is it has 4 KB
ROM and it also comprise of data memory (RAM) of 128 bytes.
Bus: Bus is a group of wires which uses as a communication canal or acts as means of data
transfer. The different bus configuration includes 8, 16 or more cables. Therefore, a bus can
bear 8 bits, 16 bits all together.
Types of buses in 8051 Microcontroller:
Let's see the two types of bus used in 8051 microcontroller:
o Address Bus: 8051 microcontrollers is consisting of 16 bit address bus. It is generally
be used for transferring the data from Central Processing Unit to Memory.
o Data bus: 8051 microcontroller is consisting of 8 bits data bus. It is generally be used
for transferring the data from one peripherals position to other peripherals.
o Oscillator: As the microcontroller is digital circuit therefore it needs timer for their
operation. To perform timer operation inside microcontroller it required externally
connected or on-chip oscillator. Microcontroller is used inside an embedded system for
managing the function of devices. Therefore, 8051 uses the two 16 bit counters and
timers. For the operation of this timers and counters the oscillator is used inside
microcontroller.
www.youtube.com/watch?v=liRPtvj7bFU&noredirect=1
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 28-32)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Introduction :
8051 microcontrollers have 4 I/O ports each of 8-bit, which can be configured as
input or output. Hence, total 32 input/output pins allow the microcontroller to be
connected with the peripheral devices. Pin configuration, i.e. the pin can be configured as 1
for input and 0 for output as per the logic state.
Prerequisite knowledge for Complete understanding and learning of Topic:
Architecture of 8051
In 8051 Microcontroller, I/O operations are performed by using four ports and 40 pins. I/O
operation port uses 32 pins with each port has 8 pins. The remaining 8-pins are used for
providing
Let's see the 40-Pin Plastic Dual Inline Package (PDIP) integrated circuit of microcontroller:
In DIP structure of microcontroller we can recognize the first and last pin by using the cut
present at middle of IC this cut is called as Notch of microcontroller. The first pin is present
at left side of notch and last pin is present at right side of notch.
In microcontroller there are four Input/output ports P0, P1, P2, and P3, each port is 8-bit port
having 8 pins each. During RESET, all the ports are used as input ports. When the port gets first
0, then it becomes an output port. For reconfigure it as an input, the high signal (1) must be sent
to a port.
Port 0 (Pin No 32 - Pin No 39):
Port 0 contains 8 pins. It can be used as input or output. In general we connect P0 with 10K-ohm
pull-up resistors for using it as an input or output port being an open drain.
It is also referred as AD0-AD7, which allowing it to be used as both address and data transfer
port. When we want to excess the external ROM, then P0 is used as both Data and Address Bus.
Let's see the structure of port 0 with externally connected pull up resistor:
Let's see an assembly language code for making the Port 0 to be worked as an input:-
It is also an 8-bit Port and can be worked as either input or output. It doesn't require external
connected pull-up resistors because they are already present internally. Upon reset, Port 1
worked as an input port.
If port 1 is configured as an output port, then to use port 1 as input port again, we write 1 to
all bits of port 1 as shown in the below code:-
Port 2 uses a total of 8 pins and it can also be used as input and output operation. Same as Port
1, P2 also not require external pull- up resistors. Port 2 can be used along with P0 to provide
16-bit address for an external memory. Therefore it is designated as (A0-A7), as shown in pin
diagram.
If Port 2 is configured as an output port, then for using it as an input port again we write 1 to all
bits of port 2 as shown in the below code:-
Port 3 is also of 8 bits and it can be used as Input/output. This port provides some important
signals.
P3.1 and P3.0 are RxD (Receiver) and TxD (Transmitter) respectively and it is collectively used
for serial communication.
P3.3 and P3.2 pins are used as external interrupts.
P3.6 and P3.7 are Write (WR) and Read (RD) pins.
13 INT 1 P3.3
It is a mostly used feature of 8051 while writing code for 8051. Sometimes there is a need to use
only 1 or 2 bits of the port instead of using entire 8-bits. 8051 microcontroller provides the feature
to use each bit of the ports.
While using a port in a single-bit manner, we provide the syntax "SETB X.Y", where X is the
port number varies from 0 to 3, and Y is a bit number varies from 0 to 7.
https://www.youtube.com/watch?v=WU8uvapSIic
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 Page No: 93-106
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Introduction :
8051 microcontroller families (89C51, 8751, DS89C4xO, 89C52) come in
different packages like quad-flat package, leadless chip carrier and dual-in-line package.
These all packages consist of 40 pins which are dedicated to several functions such as I/O,
address, RD, WR, data and interrupts. But, some companies offer a 20-pin version of
the microcontrollers for less demanding applications by reducing the number of I/O ports.
Nevertheless, a vast majority of developers use the 40-pin chip.
Pins 1-8: These pins belongs to Port 1 of microcontroller. Port 1 is used as domestically pulled
up, quasi bi directional input/output port.
Pin 9: It is a RESET pin which is utilized to set the microcontroller 8051 to its primary value.
During the beginning of an application the RESET pin is to be set elevated for two machine
rotations.
Pins 10-17: These pins belong to Port 3 of microcontroller. Port 3 can be used for number of
functions such as timer input, interrupts, serial communication indicator for transmitting
(TxD) and receiving (RxD). It is also known as domestic pull up port with quasi bi direction
port embedded within.
Pins 18 and 19: These pins are generally be used for interfacing outer crystal oscillator with
given system clock.
Pin 20: This pin titled as Vss. It symbolizes ground voltage or 0 V is connected to this pin of
microcontroller.
Pin 21-28: These pins belong to port 2 of microcontroller. Port 2 can be used as Input/output
port, senior order address bus are multiplexed with this quasi bi directional port.
Pin 29: This pin belongs to Program Store Enable or PSEN. It is used for interpreting the sign
from outer program memory.
Pin 30: This pin belongs to External Access or EA input is used for permit or prohibits
outer memory interfacing. If there is no outer memory need, this pin is set to high by
linking it with supply voltage .
Pin 31: This pin belongs to Address Latch Enable or ALE is used for de-multiplexing the
address data indication of port 0 for outer memory interfacing.
Pin 32-39: These pins belong to Port 0 of the microcontroller. Port 0 can be used as
input/output port, lower order address and data bus signals are multiplexed with this port.
This pin act as bi directional Input/output port and outer connected pull up resistors are
necessary for utilizing these ports as Input/output.
Pin 40: This pin is used to provide power supply to the circuit.
https://www.youtube.com/watch?v=ii7PCV2zvms
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 218-223)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L14
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Introduction :
An 8051 Instruction consists of an Opcode (short of Operation – Code)
followed by Operand(s) of size Zero Byte, One Byte or Two Bytes. The Op-Code part of
the instruction contains the Mnemonic, which specifies the type of operation to be performed.
One-Byte Instructions
A 1-byte instruction includes the opcode and operand in the same byte.
Operand(s) are internal register and are coded into the instruction
These instructions are 1-byte instructions performing three different tasks. In the first
instruction, both operand registers are specified. In the second instruction, the operand
B is specified and the accumulator is assumed. Similarly, in the third instruction, the
accumulator is assumed to be the implicit operand. These instructions are stored in 8-
bit binary format in memory; each requires one memory location
MOV rd, rs
Two-Byte Instructions
In a two-byte instruction, the first byte specifies the operation code and the second
byte specifies the operand. Source operand is a data byte immediately following the
opcode. For example
MVI r,data
r <-- data
Example: MVI A,30H coded as 3EH 30H as two contiguous bytes. This is an
example of immediate addressing.
ADI data
A <-- A + data
OUT port
0011 1110
DATA
where port is an 8-bit device address. (Port) <-- A. Since the byte is not the data but
points directly to where it is located this is called direct addressing.
Three-Byte Instructions
In a three-byte instruction, the first byte specifies the opcode, and the following
two bytes specify the 16-bit address. Note that the second byte is the low-order
address
and the third byte is the high-order address.
opcode + data byte + data byte
This instruction would require three memory locations to store in memory. Three byte
instructions - opcode + data byte + data byte
LXI rp, data16
rp is one of the pairs of registers BC, DE, HL used as 16-bit registers. The two data bytes
are 16-bit data in L H order of significance.
rp <-- data16
LXI H,0520H coded as 21H 20H 50H in three bytes. This is also immediate addressing.
LDA addr
A <-- (addr) Addr is a 16-bit address in L H order. Example: LDA 2134H coded as
3AH 34H 21H. This is also an example of direct addressing.
https://www.youtube.com/watch?v=0uKdlNT0EMU
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller
and Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 Page No:
(70-75)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L 15
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Introduction :
An 8051 Instruction consists of an Opcode (short of Operation – Code)
followed by Operand(s) of size Zero Byte, One Byte or Two Bytes. The Op-Code
part of the instruction contains the Mnemonic, which specifies the type of operation
to be performed.
Prerequisite knowledge for Complete understanding and learning of Topic:
Architecture
Pin diagram
Detailed content of the Lecture:
An instruction is a command to the microprocessor to perform a given task on a
specified data. Each instruction has two parts: one is task to be performed, called the
Operation code (opcode), and the second is the data to be operated on, called the
operand. The operand (or data) can be specified in various ways. It may include 8-bit
(or 16-bit ) data, an internal register, a memory location, or 8-bit (or 16-bit) address.
In some instructions, the operand is implicit. An instruction is a binary pattern
designed inside a microprocessor to perform a specific function.
The entire group of instructions, called the instruction set, determines what functions
the microprocessor can perform.
These instructions can be classified into the following five functional categories:
data transfer (copy) operations, arithmetic operations, logical operations,
branching operations, and machine-control operations.
The data transfer instructions move data between registers or between memory and
registers.
MOV Move
MVI Move Immediate
LDA Load Accumulator Directly from Memory
STA Store Accumulator Directly in Memory
LHLD Load H & L Registers Directly from
Memory
SHLD Store H & L Registers Directly in Memory
An 'X' in the name of a data transfer instruction implies that it deals with a register
pair (16-bits);
LXI Load Register Pair with Immediate data
LDAX Load Accumulator from Address in Register Pair STAX Store Accumulator in
Address in Register Pair XCHG Exchange H & L with D & E
XTHL Exchange Top of Stack with H & L
ARITHMETIC GROUP
The arithmetic instructions add, subtract, increment, or decrement data in registers
or memory.
LOGICAL GROUP
This group performs logical (Boolean) operations on data in registers and
memory condition flags.
The logical AND, OR, and Exclusive OR instructions enable you to set
specific bits in the
ANA Logical AND with Accumulator
ANI Logical AND with Accumulator Using Immediate Data
ORA Logical OR with Accumulator
OR Logical OR with Accumulator Using Immediate Data
XRA Exclusive Logical OR with Accumulator
XRI Exclusive OR Using Immediate Data
The Compare instructions compare the content of an 8-bit value with the
contents of the accumulator;
CMP Compare
CPI Compare Using Immediate Data
The rotate instructions shift the contents of the accumulator one bit position to
the left or right:
RLC Rotate Accumulator Left RRC Rotate Accumulator Right RAL Rotate Left
Through Carry RAR Rotate Right Through Carry
Complement and carry flag instructions: CMA Complement Accumulator
CMC Complement Carry Flag
STC Set Carry Flag
BRANCH GROUP
JPE CPE RPE (Parity Even) JP0 CPO RPO (Parity Odd)
Two other instructions can affect a branch by replacing the contents or the program
counter:
PCHL Move H & L to Program Counter RST Special Restart Instruction Used with
Interrupts
POP Pop Two Bytes of Data off the Stack XTHL Exchange Top of Stack with H & L
SPHL Move content of H & L to Stack Pointer
I/0 INSTRUCTIONS
IN Initiate Input Operation
OUT Initiate Output Operation
https://www.youtube.com/watch?v=0uKdlNT0EMU
Important Books/Journals for further learning including the page nos.:
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller
and Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 Page No:
70- 75
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L16
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Introduction :
There are 5 different ways to execute this instruction and hence we say, we have got
5 addressing modes for 8051. They are 1) Immediate addressing mode 2) Direct addressing
mode 3) Register direct addressing mode 4) Register indirect addressing mode 5)
Indexed addressing mode.
Prerequisite knowledge for Complete understanding and learning of Topic:
Instruction Set
Detailed content of the Lecture:
The instructions MOV B, A or MVI A, 82H are to copy data from a source into a
destination. In these instructions the source can be a register, an input port, or an 8-bit
number (00H to FFH).
Similarly, a destination can be a register or an output port. The sources and destination
are operands.
The various formats for specifying operands are called the ADDRESSING MODES. For
8085, they are:
1. Immediate addressing.
2. Register addressing.
3. Direct addressing.
4. Indirect addressing.
5. Indexed addressing mode.
(1)Immediate addressing
Data is present in the instruction. Load the immediate data to the destination
provided.
Used to accept data from outside devices to store in the accumulator or send the data
stored in the accumulator to the outside device. Accept the data from the port 00H and
store them into the accumulator or Send the data from the accumulator to the port
01H.
https://www.youtube.com/watch?v=sLbw1stNkXM
Important Books/Journals for further learning including the page nos.:
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 Page No: 109-131
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L17
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Introduction :
The timing diagram depicts the machine cycles generated for each instruction.
Instruction Cycle
The time required to execute an instruction is called instruction cycle.
Machine Cycle
The time required to access the memory or input/output devices is called
machine cycle.
T-State
The machine cycle and instruction cycle takes multiple clock periods.
A portion of an operation carried out in one system clock period is called as T-state
The 8085 microprocessor has 5 (seven) basic machine cycles. They are
Clock Signal
https://www.youtube.com/watch?v=2thCkcQj58Y
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller
and Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 Page No:
(239-240)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University) Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Introduction :
The timing diagram depicts the machine cycles generated for each instruction.
Architecture of 8051
Instruction set
Addressing modes
o The time taken by the processor to execute the opcode fetch cycle is 4T.
o In this time, the first, 3 T-states are used for fetching the opcode from memory
and the remaining T-states are used for internal operations by the processor.
2. Memory Read Machine Cycle of 8051:
The memory read machine cycle is executed by the processor to read a data byte from
memory.
The processor takes 3T states to execute this cycle.
The instructions which have more than one byte word size will use the machine cycle
after the opcode fetch machine cycle.
The memory write machine cycle is executed by the processor to write a data byte in a
memory location.
The processor takes 3T states to execute this machine cycle.
Memory Write Machine Cycle
o The I/O Read cycle is executed by the processor to read a data byte from I/O
port or from the peripheral, which is I/O, mapped in the system.
o The processor takes 3T states to execute this machine cycle.
o The IN instruction uses this machine cycle during the execution.
Timing diagram for INR M
Fetching the Opcode 34H from the memory 4105H. (OF cycle)
Let the memory address (M) be 4250H. (MR cycle -To read Memory address and data) Let the
content of that memory is 12H.
Increment the memory content from 12H to 13H. (MW machine cycle
Video Content / Details of website for further learning (if any):
https://www.youtube.com/watch?v=2thCkcQj58Y
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 Page No: (255-260)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L19
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
200E HLT
LDA 2050 moves the contents of 2050 memory location to the accumulator.
MOV H, A copies contents of Accumulator to register H to A
LDA 2051 moves the contents of 2051 memory location to the accumulator.
ADD H adds contents of A (Accumulator) and H register (F9). The result is stored in A
itself. For all arithmetic instructions A is by default an operand and A stores the
result as well
MOV L, A copies contents of A (34) to L
MVI A 00 moves immediate data (i.e., 00) to A
ADC A adds contents of A(00), contents of register specified (i.e A) and carry (1). As
ADC is also an arithmetic operation, A is by default an operand and A stores the result
as well
MOV H, A copies contents of A (01) to H
SHLD 3050 moves the contents of L register (34) in 3050 memory location and contents
of H register (01) in 3051 memory location
HLT stops executing the program and halts any further execution
Video Content / Details of website for further learning (if any):
https://www.geeksforgeeks.org › microprocessor-tutorials
https://www.geeksforgeeks.org › assembly-language-program-8085-micro.
R.S. Gaonkar, ‘Microprocessor Architecture Programming and Application’, with 8085, Wiley
Eastern Ltd., New Delhi, 2013 (Page No: 135-154)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L20
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
It is a
Device Type It is a microprocessor.
microcontroller.
DMA Access
NO YES, Has HOLD and HLDA signals
signals
https://www.youtube.com/watch?v=tC4WvbM3hZA
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 Page no( 37-55)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L21
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
LOOPING STRUCTURES
Loops are control structures used to repeat a given section of code a certain number of
times or until a particular condition is met.
Visual Basic has three main types of loops: for next loops, do loops and while loops.
The availability of low cost, low power and small weight, computing capability makes
it useful in different applications.
Now a days, a microprocessor based systems are used in instructions, automatic
testing product, speed control of motors, traffic light control, light control of furnaces
etc.
In the sequence of instructions to be executed, it is often necessary to transfer program
control to a different location. There are many instructions in the 8051 to achieve this.
This chapter covers the control transfer instructions available in 8051 Assembly
language.
In the first section we discuss instructions used for looping, as well as instructions for
conditional and unconditional jumps.
In the second section we examine CALL instructions and their uses.
In the third section, time delay subroutines are described for both the traditional 8051
and its newer generation.
LOOP INSTRUCTIONS
Example -1
In the program in Example 1, the R2 register is used as a counter. The counter is first set to
10. In each iteration the instruction DJNZ decrements R2 and checks its value. If R2 is not
zero, it jumps to the target address associated with the label “AGAIN”. This.looping action
continues until R2 becomes zero. After R2 becomes zero, it falls through the loop and
executes the instruction immediately below it, in this case the “MOV R5 , A” instruction.
Notice in the DJNZ instruction that the registers can be any of RO – R7. The counter can also
be a RAM location.
Example- 2
What is the maximum number of times that the loop in Example-1 can be repeated?
Solution:
Since R2 holds the count and R2 is an 8-bit register, it can hold a maximum of FFH (255
decimal); therefore, the loop can be repeated a maximum of 256 times.
https://www.youtube.com/watch?v=mz4FJE8P56g
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L22
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Problem – Write an assembly language program to count the number of ones in contents of register B and
store the result at memory location 3050.
Example :
Algorithm :
Convert the decimal number in Accumulator to its binary equivalent
Rotate the digits of the binary number right without carry
Apply a loop till count is not zero to change the values of D register and count
Copy the value of D register to accumulator and store the result
Program :
2000 MVI B 75 B ← 75
2002 MVI C 08 C ← 75
2004 MVI D 00 D ← 00
Explanation –
https://www.youtube.com/watch?v=vi4yZOWgDc8
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L23
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L24
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
This unit can then be used in programs wherever that particular task have to be
performed. A subroutine is often coded so that it can be started (called) several times and
from several places during one execution of the program, including from other subroutines,
and then branch back (return) to the next instruction after the call, once the subroutine’s task
is done.
It is implemented by using Call and Return instructions. The different types of
subroutine instructions are
Unconditional Call instruction
Conditional Call instruction
Unconditional Return instruction
Conditional Return instruction
Unconditional Call instruction
CALL address is the format for unconditional call instruction. After execution of this
instruction program control is transferred to a sub-routine whose starting address is
specified in the instruction. Value of PC (Program Counter) is transferred to the memory
stack and value of SP (Stack Pointer) is decremented by 2.
RET is the instruction used to mark the end of sub-routine. It has no parameter. After
execution of this instruction program control is transferred back to main program from where
it had stopped. Value of PC (Program Counter) is retrieved from the memory stack and value
of SP (Stack Pointer) is incremented by 2.
By these instructions program control is transferred back to main program and value
of PC is popped from stack only if condition is satisfied. There is no parameter for return
instruction.
INSTRUCTION COMMENT
Advantages of Subroutine
https://www.youtube.com/watch?v=2aCR5l26jJY
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L25
LECTURE HANDOUTS
EEE II/V
Course Name with Code: 19RAC12 / MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
PIC micro chips are designed with a Harvard architecture, and are offered in various
device families.
The baseline and mid-range families use 8-bit wide data memory, and the high-end
families use 16-bit data memory. The latest series, PIC32MZ is a 32-bit MIPS-based
microcontroller.
Instruction words are in sizes of 12-bit (PIC10 and PIC12), 14-bit (PIC16) and 24-bit (PIC24
and dsPIC). The binary representations of the machine instructions vary by family and are
shown in PIC instruction listings.
One accumulator
Register-bank switching is required to access the entire RAM of many devices
Operations and registers are not orthogonal; some instructions can address
RAM and/or immediate constants, while others can use the accumulator only.
The following stack limitations have been addressed in the PIC18 series, but still apply to earlier cores:
The hardware call stack is not addressable, so preemptive task switching cannot be implemented
Software-implemented stacks are not efficient, so it is difficult to generate reentrant code and
support local variables
https://www.youtube.com/watch?v=EY15NUjnM-A
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 112-117)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L26
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12 /MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
PIC16C6X
PIC16CXX microcontrollers typically achieve a 2:1 code compression and a 4:1 speed
improvement over other 8-bit microcontrollers in their class. The PIC16C61 device has 36
bytes of RAM and 13 I/O pins.
In addition a timer/counter is available. The PIC16C62/62A/R62 devices have 128 bytes of
RAM and 22 I/O pins. In addition, several peripheral features are available, including: three
timer/counters, one Capture/Compare/PWM module and one serial port. The Synchronous
Serial Port can be configured as either a 3-wire Serial Peripheral Interface the two-wire Inter-
Integrated Circuit (I2C) bus.
The PIC16C63/R63 devices have 192 bytes of RAM, while the PIC16C66 has 368 bytes. All
three devices have 22 I/O pins. In addition, several peripheral features are available, including:
three timer/counters, two Capture/Compare/PWM modules and two serial ports.
Architectural Overview
The high performance of the PIC16CXX family can be attributed to a number of
architectural features commonly found in RISC microprocessors. To begin with, the
PIC16CXX uses a Harvard architecture, in which, program and data are accessed from
separate memories using separate buses.
This improves bandwidth over traditional von Neumann architecture where program and
data may be fetched from the same memory using the same bus. Separating program and
data busses further allows instructions to be sized differently than 8-bit wide data words.
Instruction opcodes are 14-bits wide making it possible to have all single word instructions.
A 14-bit wide program memory access bus fetches a 14-bit instruction in a single cycle. A
two stage pipeline overlaps fetch and execution of instructions
Consequently, all instructions execute in a single cycle (200 ns @ 20 MHz) except for
program branches. The PIC16C61 addresses 1K x 14 of program memory. The
PIC16C62/62A/R62/64/64A/R64 address 2K x 14 of program memory, and the
PIC16C63/R63/65/65A/R65 devices address 4K x 14 of program memory. The
PIC16C66/67 address 8K x 14
https://www.youtube.com/watch?v=5BjrjeNYMZg
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 118-124)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L27
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12 / MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Data Memory (Bytes) x 8 128 192 192 192 192 368 368
I/O Pins 22 22 22 33 33 22 33
Capture/Compare/PWM
1 2 2 2 2 2 2
Modules
Timer Modules 3 3 3 3 3 3 3
A/D Channels 5 5 5 8 8 5 8
In-Circuit Serial Programming Yes Yes Yes Yes Yes Yes Yes
Interrupt Sources 8 11 11 12 12 11 12
ARCHITECTURAL OVERVIEW
The high performance of the PIC16CXX family can be attributed to a number of
architectural features commonly found in RISC microprocessors. To begin with, the
PIC16CXX uses a Harvard architecture, in which, program and data are accessed from
separate memo- ries using separate buses.
This improves bandwidth over traditional von Neumann architecture in which pro-
gram and data are fetched from the same memory using the same bus.
Separating program and data buses further allows instructions to be sized differently
than the 8-bit wide data word. Instruction opcodes are 14-bits wide making it possible
to have all single word instructions.
A 14-bit wide program memory access bus fetches a 14-bit instruction in a single cycle.
A two- stage pipeline overlaps fetch and execution of instructions
Program
Device Data Memory
Memory
PIC16C72 2K x 14 128 x 8
PIC16C73 4K x 14 192 x 8
PIC16C73A 4K x 14 192 x 8
PIC16C74 4K x 14 192 x 8
PIC16C74A 4K x 14 192 x 8
PIC16C76 8K x 14 368 x 8
PIC16C77 8K x 14 386 x 8
Video Content / Details of website for further learning (if any):
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 132-135)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L28
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12 /MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
Features
The ADC0809 is an 8-bit successive approximation type ADC with inbuilt 8-channel
multiplexer.
The ADC0809 is suitable for interface with 8086 microprocessor.
The ADC0809 is available as a 28 pin IC in DIP (Dual Inline Package).
The ADC0809 has a total unadjusted error of ±1 LSD (Least Significant Digit).
The ADC0808 is also same as ADC0809 except the error. The total unadjusted error in
ADC0808 is ± 1/2 LSD.
The successive approximation register (SAR) performs eight iterations to determine the digital
code for input value. The SAR is reset on the positive edge of START pulse and start the
conversion process on the falling edge of START pulse.
A conversion process will be interrupted on receipt of new START pulse. The End-Of-
Conversion (EOC) will go low between 0 and 8 clock pulses after the positive edge of START
pulse.
The ADC can be used in continuous conversion mode by tying the EOC output to START
input. In this mode an external START pulse should be applied whenever power is switched
ON.
The 256R ladder network has been provided instead of conventional R/2R ladder because of
its inherent monotonic, which guarantees no missing digital codes. Also the 256R resistor
network does not cause loadvariations on the reference voltage.
The comparator in ADC0809/ADC0808 is a chopper- stabilized comparator. It converts the DC
input signal into an AC signal, and amplifies the AC sign using high gain AC amplifier Then it
converts AC signal to DC signal.
This technique limits the drift component of the amplifier, because the drift is a DC component
and it is not amplified/passed by the AC amp1ifier. This makes the ADC extremely
insensitive to temperature, long term drift and input offset errors.
In ADC conversion process the input analog value is quantized and each quantized analog
value will have a unique binary equivalent. The quantization step in ADC0809/ADC0808 is
given by,
www.youtube.com/watch?v=liRPtvj7bFU&noredirect=1
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 449-452)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L29
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12 /MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
Interfacing Concepts
Detailed content of the Lecture:
D0-D7 :
These are the data bus lines those carry data or control word to/from the Microprocessor.
RESET :
A logic high on this line clears the control word register of 8255. All ports are set as input
ports by default after reset.
Operational Modes of 8255
Mode 0
In this mode, the ports can be used for simple input/output operations without
handshaking. If both port A and B are initialized in mode 0, the two halves of port C can be
either used together as an additional 8-bit port, or they can be used as individual 4-bit
ports. Since the two halves of port C are independent, they may be used such that one-half
is initialized as an input port while the other half is initialized as an output port. The input
output features in mode 0 are as follows:
Mode 1
When we wish to use port A or port B for handshake (strobed) input or output operation,
we initialise that port in mode 1 (port A and port B can be initilalised to operate in
different modes,ie, for eg, port A can operate in mode 0 and port B in mode 1). Some of the
pins of port C function as handshake lines.
For port B in this mode (irrespective of whether is acting as an input port or output port),
PC0, PC1 and PC2 pins function as handshake lines.
If port A is initialised as mode 1 input port, then, PC3, PC4 and PC5 function as handshake
signals. Pins PC6 and PC7 are available for use as input/output lines.
The mode 1 which supports handshaking has following features: 1. Two ports i.e. port A
and B can be use as 8-bit i/o port. 2. Each port uses three lines of port c as handshake
signal and remaining two signals can be function as i/o port. 3. interrupt logic is supported.
4. Input and Output data are latched.
Mode 2
Only group A can be initialised in this mode. Port A can be used for bidirectional
handshake data transfer. This means that data can be input or output on the same eight
lines (PA0 - PA7). Pins PC3 - PC7 are used as handshake lines for port A. The remaining
pins of port C (PC0 - PC2) can be used as input/output lines if group B is initialised in
mode 0. In this mode, the 8255 may be used to extend the system bus to a slave
microprocessor or to transfer data bytes to and from a floppy disk controller.
Bit Set/Reset (BSR) mode
In this mode only port b can be used (as an output port). Each line of port C (PC0 - PC7) can
be set/reset by suitably loading the command word register.no effect occurs in input-
output mode.
The individual bits of port c can be set or reset by sending the signal OUT instruction to the
control register.
https://www.youtube.com/watch?v=_M8hDkRAL6M
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 452-458)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L30
LECTURE HANDOUTS
EEE II/IV
Course Name with Code :19RAC12/ MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
The 8259A is designed to minimize the software and real time overhead in handling multi-
level priority interrupts. It has several modes, permitting optimization for a variety of system
requirements. The 8259A is fully upward compatible with the Intel 8259. Software originally
written for the 8259 will operate the 8259A in all 8259 equivalent modes (MCS-80/85, Non-
Buffered, Edge Triggered).
https://www.youtube.com/watch?v=d7oFD-zQpuQ
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 458-462)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L31
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
The Intel 8253 and 8254 are Programmable Interval Timers (PTIs)
designed for microprocessors to perform timing and counting functions using three
16-bit registers. Each counter has 2 input pins, i.e. Clock & Gate, and 1 pin for
“OUT” output. To operate a counter, a 16-bit count is loaded in its register. On
command, it begins to decrement the count until it reaches 0, then it generates a
pulse that can be used to interrupt the CPU.
Prerequisite knowledge for Complete understanding and learning of Topic:
Basics of Timer Concepts
Read/Write Logic:
It includes 5 signals, i.e. RD, WR, CS, and the address lines A0 & A1. In the peripheral
I/O mode, the RD and WR signals are connected to IOR and IOW, respectively. In the
memorymapped I/O mode, these are connected to MEMR and MEMW.
A1 A0 Result
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
Address lines A0 & A1 of the CPU are connected to lines A0 and A1 of the 8253/54, and
CS is tied to a decoded address. The control word register and counters are selected
according to the signals on lines A0 & A1.
A1 A0 RD WR CS Result
0 0 1 0 0 Write Counter 0
0 1 1 0 0 Write Counter 1
1 0 1 0 0 Write Counter 2
0 0 0 1 0 Read Counter 0
0 1 0 1 0 Read Counter 1
1 0 0 1 0 Read Counter 2
1 1 0 1 0 No operation
X X 1 1 0 No operation
X X X X 1 No operation
https://www.youtube.com/watch?v=ZtnhEqfw17c
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L32
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
DMA mode of transfer is the fastest among all the mode of data transfer
In this mode the device may transfer data directly / memory without any interface
from CPU
DMA is initiated only after receiving HLDA signal from CPU
DMA mode of data transfer between several device DMA controller is used.
Prerequisite knowledge for Complete understanding and learning of Topic:
Working of DMA Controller
DMA controller provides an interface between the bus and the input-output devices.
Although it transfers data without intervention of processor, it is controlled by the
processor.
The processor initiates the DMA controller by sending the starting address, Number of
words in the data block and direction of transfer of data .i.e. from I/O devices to the
memory or from main memory to I/O devices. More than one external device can be
connected to the DMA controller.
I/O buffer
The 8-bit bidirectional data buffer is interfaced with internal bus of 8237 and also with
external data bus
Timing and control unit
The control logic unit control the sequence of DMA operations of the following control
signals are AEN,MEMR,MEMW
RESET
Reset is an active high input which clears the Command, Status, Request and Temporary
registers.
READY
Ready is an input used to extend the memory read and write pulses from the 8237A to
accommodate slow memories or I/O peripheral devices.
CLOCK INPUT
Clock Input controls the internal operations of the 8237A and its rate of data transfers.
The input may be driven at up to 5 MHz
MEMR
MEMORY READ:
The Memory Read signal is an active low three- state output used to access data from the
selected memory location during a DMA Read or a memory-to-memory transfer.
MEMW
MEMORY WRITE:
The Memory Write is an active low three-state output used to write data to the selected
memory location during a DMA Write or a memory-to-memory transfer.
IOR
I/O READ:
I/O Read is a bidirectional active low three-state line.
In the Idle cycle, it is an input control signal used by the CPU to read the control registers.
In the Active cycle, it is an output control signal used by the 8237A to access data from a
peripheral during a DMA Write transfer.
IOW
I/O WRITE:
I/O Write is a bidirectional active low three-state line. In the Idle cycle, it is an input control
signal used by the CPU to load information into the 8237A
A0 – A3
ADDRESS:
The four least significant address lines are bidirectional three-state signals. In the Idle cycle
they are inputs and are used by the CPU to address the register to be loaded or read.
In the Active cycle they are outputs and provide the lower 4 bits of the output
address.
A4–A7
ADDRESS:
The four most significant address lines are three-state outputs and provide 4 bits of
address. These lines are enabled only during the DMA service.
https://www.youtube.com/watch?v=WrNicaqCS10
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L33
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
The term DMA stands for direct memory access. The hardware device used for direct
memory access is called the DMA controller.
DMA controller is a control unit, part of I/O device's interface circuit, which can
transfer blocks of data between I/O devices and main memory with minimal
intervention from the processor.
Prerequisite knowledge for Complete understanding and learning of Topic:
Architecture
Working of DMA Controller
Detailed content of the Lecture:
DMA controller provides an interface between the bus and the input-output devices.
Although it transfers data without intervention of processor, it is controlled by the
processor.
The processor initiates the DMA controller by sending the starting address, Number
of words in the data block and direction of transfer of data .i.e. from I/O devices to the
memory or from main memory to I/O devices. More than one external device can be
connected to the DMA controller.
Working of DMA Controller
If the DMA controller is free, it requests the control of bus from the processor by
raising the bus request signal. Processor grants the bus to the controller by raising
the bus grant signal, now DMA controller is the bus master.
The processor initiates the DMA controller by sending the memory addresses,
number of blocks of data to be transferred and direction of data transfer.
The DMA transfers the data in three modes which include the following.
a) Burst Mode: In this mode DMA handover the buses to CPU only after completion of whole
data transfer. Meanwhile, if the CPU requires the bus it has to stay ideal and wait for data
transfer.
b) Cycle Stealing Mode: In this mode, DMA gives control of buses to CPU after transfer of
every byte. It continuously issues a request for bus control, makes the transfer of one byte
and returns the bus. By this CPU doesn’t have to wait for a long time if it needs a bus for
higher priority task.
c) Transparent Mode: Here, DMA transfers data only when CPU is executing the instruction
which does not require the use of buses.
Advantages
DMA speedups the memory operations by bypassing the involvement of the CPU.
The work overload on the CPU decreases.
For each transfer, only a few numbers of clock cycles are required
Disadvantages
Cache coherence problem can be seen when DMA is used for data transfer.
Increases the price of the system
https://www.youtube.com/watch?v=WrNicaqCS10
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L34
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
8251 Receives parallel data from the CPU is a USART (Universal
Synchronous Asynchronous Receiver Transmitter) for serial data communication. &
Also receives serial data from the outside transmits serial data after conversion. &
transmits parallel data to the CPU after conversion
Prerequisite knowledge for Complete understanding and learning of Topic:
Communication Modes
https://www.youtube.com/watch?v=hfj1ZB2bURM
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 202-208)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L 35
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
Scan Counter
It has two modes i.e. Encoded mode and Decoded mode. In the encoded mode, the counter
provides the binary count that is to be externally decoded to provide the scan lines for the
keyboard and display.
In the decoded scan mode, the counter internally decodes the least significant 2 bits and
provides a decoded 1 out of 4 scan on SL0-SL3.
Operational Modes
There are two modes of operation on 8279 − Input Mode and Output Mode.
Input Mode
Scanned Keyboard Mode − In this mode, the key matrix can be interfaced using either
encoded or decoded scans. In the encoded scan, an 8×8 keyboard or in the decoded scan, a
4×8 keyboard can be interfaced. The code of key pressed with SHIFT and CONTROL status
is stored into the FIFO RAM.
Output Mode
Display Scan − This mode allows 8/16 character multiplexed displays to be
organized as dual 4-bit/single 8-bit display units.
Display Entry − This mode allows the data to be entered for display either from the right
side/left side.
https://www.youtube.com/watch?v=nAsnr_uG2mI
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 431-438)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L 36
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
Pin Description
I/O control and Data bus
The I/O control section controls the flow of data to the 8279 .The data bus buffer interface the
external bus of the system with internal bus of 8279 .The I/O is enabled only if CS is low The
pin A0,RD and WR select the command status or read / write operation carried out by the
CPU with 8279
DB0-DB7
These are bi directional data bus lines . The data and command word to the CPU are
transferred
CS
Chip select A low on this line enables 8279 for normal read or write operation.
A0
RD,WR
Input /output , Read / Write .The input pins enable the data buffer to receive or send data
over the data bus
Control and Timing Register
The register store the keyboard and display mode and other operating conditions performed
by CPU
CLK
RESET
This pin is used to reset 8279.A high on this line reset 8279
BD
The output pin is used to blank the display during digital switching
Scan counter
There are two ways in which scan line can be interfaced to the keyboard
The scan counter has two modes to scan key matrix and refresh the display
Encoded mode
Decoded mode
https://www.youtube.com/watch?v=nAsnr_uG2mI
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 431-438)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
EEE II / IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
Keypads are a part of HMI or Human Machine Interface and play really
important role in a small embedded system where human interaction or human input is
needed. Matrix keypads are well known for their simple architecture and ease
of interfacing with any microcontroller.
Prerequisite knowledge for Complete understanding and learning of Topic:
Interfacing functions
Detailed content of the Lecture: Keyboard Interfacing
The key board here we are interfacing is a matrix keyboard. This key board is
designed with a particular rows and columns.
These rows and columns are connected to the microcontroller through its ports of the
micro controller 8051. We normally use 8*8 matrix key board.
So only two ports of 8051 can be easily connected to the rows and columns of the key
board. Whenever a key is pressed, a row and a column gets shorted through that
pressed key and all the other keys are left open.
When a key is pressed only a bit in the port goes high. Which indicates
microcontroller that the key is pressed. By this high on the bit key in the
corresponding column is identified.
Once we are sure that one of key in the key board is pressed next our aim is to
identify that key. To do this we firstly check for particular row and then we check the
corresponding column the key board.
To check the row of the pressed key in the keyboard, one of the row is made high by
making one of bit in the output port of 8051 high .
This is done until the row is found out. Once we get the row next out job is to find out
the column of the pressed key.
The column is detected by contents in the input ports with the help of a counter. The
content of the input port is rotated with carry until the carry bit is set.
The contents of the counter is then compared and displayed in the display. This
display is designed using a seven segment display and a BCD to seven segment
decoder IC 7447.
The BCD equivalent number of counter is sent through output part of 8051 displays
the number of pressed key.
www.youtube.com/watch?v=liRtPtvj7bFU&noredirect=1
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (R1-363-370)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L38
LECTURE HANDOUTS
EEE II / IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
We can divide it in five categories, Power Pins, contrast pin, Control Pins, Data pins and
Backlight pins.
Pin
Category Pin Name Function
NO.
All the pins are clearly understandable by their name and functions, except the control pins,
so they are explained below:
RS: RS is the register select pin. We need to set it to 1, if we are sending some data to be
displayed on LCD. And we will set it to 0 if we are sending some command instruction like
clear the screen (hex code 01).
RW: This is Read/write pin, we will set it to 0, if we are going to write some data on LCD.
And set it to 1, if we are reading from LCD module. Generally this is set to 0, because we do
not have need to read data from LCD. Only one instruction “Get LCD status”, need to be read
some times.
E: This pin is used to enable the module when a high to low pulse is given to it. A pulse of
450 ns should be given. That transition from HIGH to LOW makes the module ENABLE.
Circuit Diagram and Explanation
Circuit diagram for LCD interfacing with 8051 microcontroller is shown in the above
figure. If you have basic understanding of 8051 then you must know about EA(PIN
31), XTAL1 & XTAL2, RST pin(PIN 9), Vcc and Ground Pin of 8051 microcontroller. I
have used these Pins in above circuit. If you don’t have any idea about that then I
recommend you to read this Article LED Interfacing with 8051 Microcontroller before
going through LCD interfacing.
So besides these above pins we have connected the data pins (D0-D7) of LCD to the
Port 2 (P2_0 – P2_7) microcontroller. And control pins RS, RW and E to the pin
12,13,14 (pin 2,3,4 of port 3) of microcontroller respectively.
PIN 2(VDD) and PIN 15(Backlight supply) of LCD are connected to voltage (5v), and
PIN 1 (VSS) and PIN 16(Backlight ground) are connected to ground.
Pin 3(V0) is connected to voltage (Vcc) through a variable resistor of 10k to adjust the
contrast of LCD. Middle leg of the variable resistor is connected to PIN 3 and other
two legs are connected to voltage supply and Ground.
Video Content / Details of website for further learning:
www.youtube.com/watch?v=liRtPtvj7bFU&noredirect=1
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller
and Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (R1-352-362)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L39
LECTURE HANDOUTS
EEE II / IV
Course Name with Code:19RAC12/MICROPROCESSORS AND APPICATIONS
Date of Lecture:
Introduction :
Stepper Motor Control using 8051 Microcontroller. A stepper motor is a
brushless and synchronous motor which divides the complete rotation into number of steps.
Each stepper motor will have some fixed step angle and motor rotates at this angle.
Prerequisite knowledge for Complete understanding and learning of Topic:
Stepper Motor
A stepper motor is a device that translates electrical pulses into
mechanical movement in steps of fixed step angle.
It is used in disk drives, dot matrix printers, plotters and robotics and process
control circuits.
The complete board consists of transformer, control circuit, keypad and stepper motor as
shown in snap.
The circuit has inbuilt 5 V power supply so when it is connected with transformer
it will give the supply to circuit and motor both. The 8 Key keypad is connected with
circuit through which user can give the command to control stepper motor. The control
circuit includes micro controller 89C51, indicating LEDs, and current driver chip
ULN2003A. One can program the controller to control the operation of stepper motor. He
can give different commands through keypad like, run clockwise, run anticlockwise,
increase/decrease RPM, increase/decrease revolutions, stop motor, change the mode, etc.
Unipolar stepper motor:- unipolar stepper motor has four coils. One end of each coil is
tied together and it gives common terminal which is always connected with positive
terminal of supply. The other ends of each coil are given for interface. Specific color code
may also be given. Like in my motor orange is first coil (L1), brown is second (L2),
yellow is third (L3), black is fourth (L4) and red for common terminal.
The circuit consists of very few components. The major components are 7805, 89C51 and
ULN2003A.
Connections:-
1. The transformer terminals are given to bridge rectifier to generate rectified DC.
2. It is filtered and given to regulator IC 7805 to generate 5 V pure DC. LED indicates
supply is ON.
3. All the push button micro switches J1 to J8 are connected with port P1 as shown to form
serial keyboard.
4. 12 MHz crystal is connected to oscillator terminals of 89C51 with two biasing capacitors.
5. All the LEDs are connected to port P0 as shown
6. Port P2 drives stepper motor through current driver chip ULN2003A.
7. The common terminal of motor is connected to Vcc and rest all four terminals are
connected to port P2 pins in sequence through ULN chip.
Video Content / Details of website for further learning (if any):
www.youtube.com/watch?v=liRtPtvj7bFU&noredirect=1
Important Books/Journals for further learning including the page nos.:
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L40
LECTURE HANDOUTS
EEE II / V
Course Name with Code: 19RAC12/MICROPROCESSORS AND MICROCONTROLLERS
Date of Lecture:
Introduction :
A stepper motor is a device that translates electrical pulses into mechanical
movement in steps of fixed step angle.
The stepper motor rotates in steps in response to the applied signals.
It is mainly used for position control.
It is used in disk drives, dot matrix printers, plotters and robotics and process control
circuits.
Prerequisite knowledge for Complete understanding and learning of Topic:
Interfacing
Motor Driver Circuit
Stepper motor and its operation
Detailed content of the Lecture: Stepper motor Control
Stepper motors have a permanent magnet called rotor (also called the shaft)
surrounded by a stator. The most common stepper motors have four stator windings
that are paired with a center-tap. This type of stepper motor is commonly referred to
as a four-phase or unipolar stepper motor.
The center tap allows a change of current direction in each of two coils when a
winding is grounded, thereby resulting in a polarity change of the stator.
Interfacing
Even a small stepper motor require a current of 400 mA for its operation.
But the ports of the microcontroller cannot source this much amount of current. If
such a motor is directly connected to the microprocessor/microcontroller ports, the
motor may draw large current from the ports and damage it. So a suitable driver
circuit is used with the microprocessor/microcontroller to operate the motor.
Motor Driver Circuit (ULN2003)
Stepper motor driver circuits are available readily in the form of ICs. ULN2003 is one
such driver IC which is a High-Voltage High-Current Darlington transistor array and
can give a current of 500mA.This current is sufficient to drive a small stepper motor.
Internally, it has protection diodes used to protect the motor from damage due to
back emf and large eddy currents. So, this ULN2003 is used as a driver to interface
the stepper motor to the microcontroller.
Operation
The important parameter of a stepper motor is the step angle.
It is the minimum angle through which the motor rotates in response to each
excitation pulse. In a four phase motor if there are 200 steps in one complete rotation
then then the step angle is 360/200 = 1.8O . So to rotate the stepper motor we have to
apply the excitation pulse. For this the controller should send a hexa decimal code
through one of its ports.
The hex code mainly depends on the construction of the stepper motor. So, all the
stepper motors do not have the same Hex code for their rotation. (refer the operation
manual supplied by the manufacturer.) For example, let us consider the hex code for
a stepper motor to rotate in clockwise direction is 77H , BBH , DDH and EEH. This
hex code will be applied to the input terminals of the driver through the assembly
language program
ASSEMBLY LANGUAGE PROGRAM (8051)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L41
LECTURE HANDOUTS
EEE II / IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
AT89S51 microcontroller is used to control the process of washing cycle and
to drive the external output devices such as water inlet valve, wash motor, water drain valve.
The control strategy program for AT89S51 microcontroller is implemented by using assembly
language.
Prerequisite knowledge for Complete understanding and learning of Topic:
Many washing m/c shell in the market has mechanical controlled sequence for
activated the timer and the sequence back and forth for their motor; washing
motor or spinning motor. Spinning motor control only has one direction only, and its
simple could be changed to the discrete mechanical timer which sells on the market.
But washing motor control has 2 direction
for this purpose, it means to squeeze the clothes, it must go to forward and then
reversed. The sequence is like this :
First, go to forward direction for about a few seconds
Than stop, while the chamber is still rotate
Second, go back to reverse direction for about a few seconds
Than stop, while the chamber is still rotate
And so on, back and forth, until the the timer elapsed
SCHEMATIC
Timing sequence like the above description, can be implemented with many way, by
using discrete electronic components, timer, using a program or a
microcontroller or microprocessor, etc.
Because I am learning the PIC microcontroller for right now, I will implement this
function using this microcontroller, but for you who familiar with another kind of
microcontroller my adapted it to your purpose.
By using PIC micro, it can be made more compact. First I plan to make 2 buttons,
1 for set the timer and another for reset the timer or for the emergency stop push
button. Then to know the timer works or not, I need a visual display. For this
purpose I will use
7-segmen display showing the rest of the timer. To run the motor sequence of
course I need a pair of relays (power relays, about 3 Amperes output), one for
forward and another for reverse option.
I will use the very common family of PIC micro, ie : 16F84A, because this is the most
popular type and very simples used and very much used. Also can be obtained
easily in the market. But this is the medium type of PIC micro family.
It has 1kByte of memory (EEPROM type) and 13 I/O pins. It can be
reprogrammable thousands times. Because the I/O just only 13 pins, I used a BCD to
7-segmen chip. So it will left a few I/O pins for expanded in the future. You can
omitted this chip for timing sequence purpose and save one IC price, because the
I/O just exactly enough.
www.youtube.com/watch?v=liRtPtvj7bFU&noredirect=1
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L42
LECTURE HANDOUTS
EEE II / IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
AT89S51 microcontroller is used to control the process of washing cycle and
to drive the external output devices such as water inlet valve, wash motor, water drain valve.
The control strategy program for AT89S51 microcontroller is implemented by using assembly
language.
Prerequisite knowledge for Complete understanding and learning of Topic:
Many washing m/c shell in the market has mechanical controlled sequence for
activated the timer and the sequence back and forth for their motor; washing
motor or spinning motor. Spinning motor control only has one direction only, and its
simple could be changed to the discrete mechanical timer which sells on the market.
But washing motor control has 2 direction
for this purpose, it means to squeeze the clothes, it must go to forward and then
reversed. The sequence is like this :
First, go to forward direction for about a few seconds
Than stop, while the chamber is still rotate
Second, go back to reverse direction for about a few seconds
Than stop, while the chamber is still rotate
And so on, back and forth, until the the timer elapsed
SCHEMATIC
Timing sequence like the above description, can be implemented with many way, by
using discrete electronic components, timer, using a program or a
microcontroller or microprocessor, etc.
Because I am learning the PIC microcontroller for right now, I will implement this
function using this microcontroller, but for you who familiar with another kind of
microcontroller my adapted it to your purpose.
By using PIC micro, it can be made more compact. First I plan to make 2 buttons,
1 for set the timer and another for reset the timer or for the emergency stop push
button. Then to know the timer works or not, I need a visual display. For this
purpose I will use
7-segmen display showing the rest of the timer. To run the motor sequence of
course I need a pair of relays (power relays, about 3 Amperes output), one for
forward and another for reverse option.
I will use the very common family of PIC micro, ie : 16F84A, because this is the most
popular type and very simples used and very much used. Also can be obtained
easily in the market. But this is the medium type of PIC micro family.
It has 1kByte of memory (EEPROM type) and 13 I/O pins. It can be
reprogrammable thousands times. Because the I/O just only 13 pins, I used a BCD to
7-segmen chip. So it will left a few I/O pins for expanded in the future. You can
omitted this chip for timing sequence purpose and save one IC price, because the
I/O just exactly enough.
www.youtube.com/watch?v=liRtPtvj7bFU&noredirect=1
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L 43
LECTURE HANDOUTS
EEE II/IV
Course Name with Code : 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
The main principle of this circuit is to interface LEDs to the 8051 family micro controller.
Commonly, used LEDs will have voltage drop of 1.7v and current of 10mA to glow at
full intensity. This is applied through the output pin of the micro controller.
Prerequisite knowledge for Complete understanding and learning of Topic:
LED
Interfacing of 8051
Detailed content of the Lecture: LED control
8051 has an on-chip oscillator, but it requires an external clock to run it. A quartz crystal is
connected in between the XTAL pins of the MC. This crystal needs two same value
capacitors (33pF) for generating a clock signal of the desired frequency. Features of 8051
Microcontroller have explained in our previous article.
LED (Light Emitting Diode)
LED is a semiconductor device used in many electronic devices, mostly used for signal
transmission /power indication purposes. It is very cheaply and easily available in a variety of
shape, color, and size. The LEDs are also used for design message display boards and traffic
control signal lights etc.
It has two terminals positive and negative as shown in the figure.
The only way to know polarity is either to test it with a multimeter or by carefully observing
inside the LED. The larger end inside the led is -ve (cathode) and the shorter one is +ve (anode),
that is how we find out the polarity of the LED. Another way to recognize the polarity is,
connecting leads, POSITIVE terminal has more length than NEGATIVE terminal.
There are two ways which we can interface LED to the Microcontroller 8051. But the
connections and programming techniques will be different. This article provides the information
on LED interfacing with 8051 and LED blinking code for AT89C52/ AT89C51 Microcontroller.
Interfacing LED to 8051 Methods
Observe carefully the interface LED 2 is in forward biased because the input voltage of 5v
connected to the positive terminal of the LED, So here the Microcontroller pin should be at LOW
level. And vice versa with the interface 1 connections.
The resistor is important in LED interfacing to limit the flowing current and avoid damaging the
LED and/or MCU.
Interface 1 will glow LED, only if the PIN value of the MC is HIGH as current flows towards
the ground.
Interface 2 will glow LED, only if the PIN value of the MC is LOW as current flows towards
PIN due to its lower potential.
The circuit diagram is shown in below. An LED is connected to the pin-0 of port-1.
https://www.electronicshub.org › led-interfacing-8051
Important Books/Journals for further learning including the page nos.:
Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely, The 8051 Micro Controller and
Embedded Systems, PHI Pearson Education, 5th Indian reprint, 2003 (Page No: 476-481)
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L 44
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
Servo motors are very useful in electronics and embedded systems. You can
find the use of Servo motor everywhere around you, they are used in toys, robots, CD tray of
computer, cars, aeroplane etc. The reason of this wide scope is that, servo motor is very
reliable and precise.
We can rotate it to any particular angle. They are available in wide range, form
high torque motor to low torque motors. In this tutorial we are going to interface a servo
motor to 8051 microcontroller (AT89S52).
Prerequisite knowledge for Complete understanding and learning of Topic:
Servo motor interfacing with 8051 microcontroller, the black wire connected to the
ground pin and the motor get the power from the red wire. The control of servo motor
connected port0 of 8051 microcontroller.
The 11.0592MHz crystal oscillator is used to provide the clock pulsed to the
microcontroller and 22pf ceramic capacitors used to stabilize the operation of crystal.
10KΩ and 10uf capacitor is used to provide the power on reset to the microcontroller.
Servo Motor Working Principle
The servo motor working principle mainly depends upon the ‘Fleming left hand rule’.
Basically servo motors are adapted with DC motors, a position sensor, a Gear
reduction, and an electronic circuit.
The DC motors achieve powered from a battery and run at high speed and low torque.
We assembled shaft and gear connected to DC motors then we can increase and
decrease the motor speed gradually.
Servo Motor Applications
If a motor gets heavy load the driver will increase the current to the motor coil as its
efforts to rotate the motor. Mainly, there is no out-of-step condition.
High-speed operation is possible by the servo motors.
Video Content / Details of website for further learning (if any):
www.youtube.com/watch?v=liRtPtvj7bFU&noredirect=1
Course Faculty
MUTHAYAMMAL ENGINEERING COLLEGE
(An Autonomous Institution)
(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu
L 45
LECTURE HANDOUTS
EEE II/IV
Course Name with Code: 19RAC12/MICROPROCESSORS AND APPLICATIONS
Date of Lecture:
Introduction :
Servo motors are very useful in electronics and embedded systems. You can
find the use of Servo motor everywhere around you, they are used in toys, robots, CD tray of
computer, cars, aeroplane etc. The reason of this wide scope is that, servo motor is very
reliable and precise.
We can rotate it to any particular angle. They are available in wide range, form
high torque motor to low torque motors. In this tutorial we are going to interface a servo
motor to 8051 microcontroller (AT89S52).
Prerequisite knowledge for Complete understanding and learning of Topic:
Servo motor interfacing with 8051 microcontroller, the black wire connected to the
ground pin and the motor get the power from the red wire. The control of servo motor
connected port0 of 8051 microcontroller.
The 11.0592MHz crystal oscillator is used to provide the clock pulsed to the
microcontroller and 22pf ceramic capacitors used to stabilize the operation of crystal.
10KΩ and 10uf capacitor is used to provide the power on reset to the microcontroller.
Servo Motor Working Principle
The servo motor working principle mainly depends upon the ‘Fleming left hand rule’.
Basically servo motors are adapted with DC motors, a position sensor, a Gear
reduction, and an electronic circuit.
The DC motors achieve powered from a battery and run at high speed and low torque.
We assembled shaft and gear connected to DC motors then we can increase and
decrease the motor speed gradually.
Servo Motor Applications
If a motor gets heavy load the driver will increase the current to the motor coil as its
efforts to rotate the motor. Mainly, there is no out-of-step condition.
High-speed operation is possible by the servo motors.
Video Content / Details of website for further learning (if any):
www.youtube.com/watch?v=liRtPtvj7bFU&noredirect=1
Course Faculty